|
- local MJRoomToolView=MJFramework.MJImport("mj.luaScript.Views.Room.MJRoomToolView")
- local MJRoomMessageView=MJFramework.MJImport("mj.luaScript.Views.Room.MJRoomMessageView")
- local MJRoomPlayerView=MJFramework.MJImport("mj.luaScript.Views.Room.MJRoomPlayerView")
- local MJDefine=MJFramework.MJImport("mj.luaScript.MJDefine")
- local MJHandCardView=MJFramework.MJImport("mj.luaScript.Views.Game.MJHandCardView")
- local MJRoomXiaoJuView=MJFramework.MJImport("mj.luaScript.Views.Room.MJRoomXiaoJuView")
- local MJRoomDaJuView=MJFramework.MJImport("mj.luaScript.Views.Room.MJRoomDaJuView")
- local MJRoomDismissView=MJFramework.MJImport("mj.luaScript.Views.Room.MJRoomDismissView")
- local MJRoomDirection=MJFramework.MJImport("mj.luaScript.Views.Room.MJRoomDirection")
- local MJMessage=MJFramework.MJImport("mj.luaScript.Protocol.MJMessage")
- local MJ=MJFramework.MJImport("mj.luaScript.Views.Game.MJ")
- local MJWanFa=MJFramework.ImportWanFa("luaScript.SubGameDefine.MaJiang.MJWanFa")
- local MJAnimationCompnent=MJFramework.MJImport("mj.luaScript.Views.Compnent.MJAnimationCompnent")
- local MJFunction=MJFramework.MJImport("mj.luaScript.MJFunction")
- local MJSound=MJFramework.MJImport("mj.luaScript.MJSound")
-
- local MJRoomView = class("MJRoomView", cc.UIView)
-
- function MJRoomView:ctor()
- MJRoomView.super.ctor(self);
- --玩家牌局面板
- self.playerHandCards={}
-
- if app.systemSetting.info.viewType == MJDefine.DesktopType.TwoD then -- viewType只保存2d 3d类型 mj_desktop_2d_mjType保存2d麻将类型
- local value = loadUserInfo("mj_desktop_2d_mjType")
- if value=="" or not value then
- value = MJDefine.DesktopType.TwoD
- saveUserInfo("mj_desktop_2d_mjType", value)
- end
- self.desktopType = value
- else
- self.desktopType = app.systemSetting.info.viewType
- end
-
- cc.Director:getInstance():getEventDispatcher():addEventListenerWithFixedPriority(
- cc.EventListenerCustom:create("applicationScreenSizeChanged" , handler(self, self.applicationScreenSizeChanged)), 1
- )
- end
-
- function MJRoomView:onEnter()
- MJRoomView.super.onEnter(self)
- --ui load
- self:loadUi()
-
- self:changeGameBg()
-
- -- 初始化GPS组件
- self:initGpsComponent();
-
- --加载纹理缓存
- self:loadTextureCache()
-
- -- --初始化视图
- self:initView()
-
- -- --初始化游戏事件按钮
- self:initGameButton()
-
- --默认状态
- self:defaultState()
- -- --监听事件
- self:bindAllEvent()
-
- self:onGameReconnection()
-
- self:startGame()
-
- MJSound.PlayGameBGM()
-
- self:changeWaterMark()
- -- playLHQMusic()
-
- self:initPlayGameAgain()
- self:checkCanDismiss()
- end
-
- function MJRoomView:loadUi()
- local ui = loadUI("mj/res/ui/ui_fangjian/mj_ui_fangjian.ui");
- self.ui = ui;
- self:addChild(ui);
- end
- ---
- -- 初始化大结算再来一局
- -- @return
- --
- function MJRoomView:initPlayGameAgain()
- local strGameInfo = app.room.roomInfo.strGameInfo
- local isInClub = app.club_php.clubID and app.club_php.clubID ~= 0
- if not isInClub then
- logD("IPlayGameAgain.initPlayGameAgain", "当前玩家不在亲友圈内,不能再来一局");
- return
- end
-
- local clubGameInfo = json.decode(strGameInfo) or {}
- if not clubGameInfo.ruleid then
- logD("IPlayGameAgain.initPlayGameAgain", "游戏包间id不存在,不能再来一局");
- return
- end
-
- dd.IPlayGameAgain.setAgainGameBaoJianId(clubGameInfo.ruleid)
- end
-
- --更换水印,不同平台水印不同,在子游戏配置里面配置图片
- function MJRoomView:changeWaterMark()
- --[[ local roomInfo = app.room.roomInfo
- roomInfo.gameId = roomInfo.gameId or 0
- local config = getSubGameConfig(roomInfo.gameId ~= 0 and roomInfo.gameId or app.gameId)
- if config and config.logo and self.ui.Items.ImageView_Logo then
- self.ui.Items.ImageView_Logo:loadTexture(config.logo,0)
- end
-
- if config.isShowLogo ~= nil then
- self.ui.Items.ImageView_Logo:setVisible(config.isShowLogo);
- end--]]
- self:initLogo()
- end
-
- -- 水印
- function MJRoomView:initLogo()
- if tolua.isnull(self.ui.Items.ImageView_Logo) then return end
- if not (type(getSubGameRoomLogo) == 'function') then--大厅不支持此方法,则隐藏logo
- self.ui.Items.ImageView_Logo:setVisible(false);
- return
- end
- local roomInfo = app.room.roomInfo
- local gameInfo = json.decode(roomInfo.strGameInfo or "")
- local gamerule = tonumber(gameInfo.gamerule or 1)
- roomInfo.gameId = roomInfo.gameId or MJDefine.GameID or 0
- local logofile = getSubGameRoomLogo(roomInfo.gameId,gamerule)
- if logofile then
- self.ui.Items.ImageView_Logo:loadTexture(logofile)
- self.ui.Items.ImageView_Logo:setVisible(true);
- else
- self.ui.Items.ImageView_Logo:setVisible(false);
- end
- end
-
- --更换背景 是否更新桌面参数 (设置下局生效的时候需要)
- function MJRoomView:changeGameBg(isUpdateViewType)
-
- if isUpdateViewType then
-
- if app.systemSetting.info.viewType == MJDefine.DesktopType.TwoD then --更新2D麻将类型 金色还是绿色
- local value = loadUserInfo("mj_desktop_2d_mjType") --or MJDefine.DesktopType.TwoD
- if value=="" or not value then
- value = MJDefine.DesktopType.TwoD
- saveUserInfo("mj_desktop_2d_mjType", value)
- end
- logD("changeGameBg value:"..value)
- -- if value ~= self.desktopType then --有改变
- -- cc.SpriteFrameCache:getInstance():removeSpriteFramesFromFile("mj/res/ui/zy_fangjian/mj_2d.plist")
- -- cc.SpriteFrameCache:getInstance():removeSpriteFramesFromFile("mj/res/ui/zy_fangjian/mj_2d_gold.plist")
- -- end
- self.desktopType = value
- else
- self.desktopType = app.systemSetting.info.viewType
- end
- self:loadTextureCache()
- logD("changeGameBg"..self.desktopType)
- end
-
- --更换2D桌面
- if self.desktopType==MJDefine.DesktopType.TwoD or self.desktopType==MJDefine.DesktopType.TwoDGold then
- local defaultValue = tonumber(loadUserInfo("mj_desktop_2d_bg")) or 1
- local bgData = MJDefine.DesktopBG[defaultValue]
- self.ui.Items.ImageView_bg:loadTexture(bgData['2d'])
- else
- local defaultValue = tonumber(loadUserInfo("mj_desktop_3d_bg")) or 1
- local bgData = MJDefine.DesktopBG[defaultValue]
- self.ui.Items.ImageView_bg:loadTexture(bgData['3d'])
- end
- end
-
- function MJRoomView:startGame()
- --起飞
- app.net:onMsgResume()
- end
-
- function MJRoomView:loadTextureCache()
- cc.SpriteFrameCache:getInstance():addSpriteFramesWithFile("res/ui/zy_fangjian/RoomMenu/RoomMenu2.plist")
- loadSpriteFrameFile("mj/res/ui/zy_fangjian/animation/xipai/mj_xipai.plist")
- local mjRes = MJDefine.MJRes[self.desktopType]
- if mjRes then
- for k,v in pairs(mjRes) do
- cc.SpriteFrameCache:getInstance():addSpriteFramesWithFile(v)
- end
- end
- end
-
-
- function MJRoomView:onExit()
- MJRoomView.super.onExit(self)
- if self.Time then
- cc.Director:getInstance():getScheduler():unscheduleScriptEntry(self.Time)
- end
-
- if self.taiPaiTimer then
- cc.Director:getInstance():getScheduler():unscheduleScriptEntry(self.taiPaiTimer)
- end
-
- if self.singleComponent then
- self.singleComponent:exit()
- end
-
- app.room:dispatchEvent({name=MJDefine.MJEvent.DismissClose});
-
- stopBGMusic()
-
- self:cleanCache()
- end
-
- function MJRoomView:initGameButton()
- --听牌按钮
- self.ui.Items.Button_Ting:registerClick(function()
- playBtnEffect()
- self.ui.Items.Button_Ting:setVisible(false)
- if self.ui.Items.Layout_Card_Panel:isVisible() then
- self.ui.Items.Layout_Card_Panel:setVisible(false)
- else
- self.ui:sendMsg(app.room,MJDefine.MJEvent.Ting)
- end
- end)
-
- -- self.ui.Items.ImageView_Ting_Animation:runAction(cc.RepeatForever:create(cc.RotateBy:create(1,30)))
- self.ui.Items.Layout_TingPai:setVisible(false)
-
- --详细按钮
- self.ui.Items.Button_Info:registerClick(function()
- playBtnEffect()
- self.ui.Items.Layout_Rule:setVisible(not self.ui.Items.Layout_Rule:isVisible())
-
- end)
- self.ui.Items.Button_Info:setVisible(false)
-
- --点击空白
- self.ui.Items.Layout_Touch:registerClick(nil,function()
-
- -- 隐藏个人信息
- self.playerView:removePlayerInfoView()
-
- self.ui.Items.Layout_Rule:setVisible(false)
- self.toolView:setMenuVisible(false,true)
-
- if self.ui.Items.Layout_Card_Panel:isVisible() and app.room:isTingStatus() then
- --self.ui.Items.Layout_TingPai:setVisible(true)
- --self.ui.Items.Button_Ting:setVisible(true)
- -- else
-
- end
-
- self.ui.Items.Layout_Card_Panel:setVisible(false)
- end)
-
- end
-
- --隐藏俱乐部
- function MJRoomView:hideClub()
- --self.ui.Items.Button_Club:setVisible(false)
-
- if self.clubView and not tolua.isnull(self.clubView) then
- self.clubView:removeFromParent()
- self.clubView=nil
- end
- end
-
-
- function MJRoomView:initHandCardNodes()
-
- -- local roomConfig={
- -- [4]={MJDefine.PlayerViewType.My,MJDefine.PlayerViewType.Left,MJDefine.PlayerViewType.Right,MJDefine.PlayerViewType.Top},
- -- [3]={MJDefine.PlayerViewType.My,MJDefine.PlayerViewType.Left,MJDefine.PlayerViewType.Right},
- -- [2]={MJDefine.PlayerViewType.My,MJDefine.PlayerViewType.Top},
- -- }
-
- --玩家手牌相关
- if MJDefine.MJRoomPlayerSitConfig[app.room:getMaxPlayerCount()] then
- for k,v in pairs(MJDefine.MJRoomPlayerSitConfig[app.room:getMaxPlayerCount()]) do
- if self.playerHandCards[v] then
- self.playerHandCards[v]:removeFromParent()
- end
- self.playerHandCards[v] = MJHandCardView:new(v,self.desktopType)
- self.ui.Items.Layout_Player:addChild(self.playerHandCards[v],v)
- end
- end
- -- for i=1,app.room.roomInfo.nMaxPlayCount do
-
- -- end
- end
-
- function MJRoomView:initView()
- --暂时隐藏牌数
- if self.ui.Items.ImageView_CardNum then
- self.ui.Items.ImageView_CardNum:setVisible(false)
- end
-
- self.direcionView = MJRoomDirection:new(self.desktopType)
- self.ui.Items.Layout_Player:addChild(self.direcionView)
- self.direcionView:setVisible(false)
-
- --加载工具层
- self.toolView = MJRoomToolView:new()
- self:addChild(self.toolView)
-
- --UI相关
- self.playerView = MJRoomPlayerView:new()
- self.toolView.ui.Items.Layout_Chat:addChild(self.playerView)
-
- self:onChangeChatEnable()
-
- --定时器
- self.ui.Items.Text_Time:setText(MJFunction.getTimeString())
- if not self.Time then
- self.Time = cc.Director:getInstance():getScheduler():scheduleScriptFunc(function()
- self.ui.Items.Text_Time:setText(MJFunction.getTimeString())
- end,1.0,false)
- end
- end
-
-
- function MJRoomView:defaultState()
- --队列初始化
- self.callbackQueue = {}
- self.callbackRunning = false
-
- --等待操作的显示
- --删除等待操作的显示
- if self.waitOperates and #self.waitOperates>0 then
- for k,v in pairs(self.waitOperates) do
- v:removeFromParent()
- end
- end
- self.waitOperates = {}
-
- self.playerView:setOffLineVisible(false)
- self.playerView:setPlayerVisible(false)
- if self.ui.Items.Layout_Rule then
- self.ui.Items.Layout_Rule:setVisible(false)
- end
-
- self:resetGame()
- end
-
- --显示查听的牌
- function MJRoomView:setChaTingCardViewVisible(bVisible,tingCards)
- if true == bVisible then
- print("---------setChaTingCardViewVisible-----------true")
- else
- print("---------setChaTingCardViewVisible-----------false")
- end
- self.ui.Items.Layout_TingPai:setVisible(bVisible)
- self.ui.Items.ListView_Cha_Ting:removeAllItems()
- self.ui.Items.ListView_Cha_Ting:getHBar():setVisible(false)
- local width=47
- local padding=8
-
- if tingCards then
- self.ui.Items.Layout_Card_Panel:setVisible(true)
- -- self.ui.Items.Layout_Card_Panel:removeAllChildren()
- if #tingCards==0 then
- local tingWidth=47+padding*2
- self.ui.Items.ListView_Cha_Ting:setSize(cc.size(tingWidth,self.ui.Items.ListView_Cha_Ting:getContentSize().height))
- self.ui.Items.Layout_Card_Panel:setSize(cc.size(tingWidth+83,self.ui.Items.Layout_Card_Panel:getContentSize().height))
-
- local layout=cc.Layout:create()
- local mj=cc.Sprite:createWithSpriteFrameName("mj_img_quanting.png")
- layout:addChild(mj)
- layout:setSize(cc.size(mj:getContentSize().width+padding,self.ui.Items.ListView_Cha_Ting:getContentSize().height))
- self.ui.Items.ListView_Cha_Ting:pushBackCustomItem(layout)
- mj:setPosition(layout:getContentSize().width/2,layout:getContentSize().height/2)
- else
- local count=#tingCards>10 and 10 or #tingCards
- local tingWidth=count*47+padding*(count+1)
- self.ui.Items.ListView_Cha_Ting:setSize(cc.size(tingWidth,self.ui.Items.ListView_Cha_Ting:getContentSize().height))
- self.ui.Items.Layout_Card_Panel:setSize(cc.size(tingWidth+83,self.ui.Items.Layout_Card_Panel:getContentSize().height))
- for k,v in pairs(tingCards) do
- local layout=cc.Layout:create()
- local mj=MJ:new(v.card,MJDefine.MJType.Out,MJDefine.MyViewId)
- -- mj:setScale(width/mj:getContentSize().width)
- layout:addChild(mj)
- layout:setSize(cc.size(width+padding,self.ui.Items.ListView_Cha_Ting:getContentSize().height))
- self.ui.Items.ListView_Cha_Ting:pushBackCustomItem(layout)
- mj:setPosition(layout:getContentSize().width/2,layout:getContentSize().height/2)--65)
-
- --数量显示
- -- local mjNumImg=cc.Sprite:createWithSpriteFrameName("mj_img_ting_num_bg.png")
- -- mjNumImg:setAnchorPoint(cc.p(1,0))
- -- mjNumImg:setPosition(mj:getContentSize().width-2,5)
- -- mj:addChild(mjNumImg)
-
- -- local mjNum = cc.Text:createNode()
- -- mjNum:setDefaults()
- -- mjNum:setAnchorPoint(cc.p(1,0))
- -- local config = mjNum:getFontConfig()
- -- config.fontSize = 30
- -- config.texColor = cc.c4b(251,213,130,255)
- -- -- config.outlineSize = 1
- -- -- config.effectColor = cc.c4b(0,0,0,255)
- -- mjNum:setFontConfig(config)
- -- mjNumImg:addChild(mjNum)
- -- mjNum:setPosition(cc.p(38,0))
- -- mjNum:setString(v.count)
- end
- end
-
- else
- self.ui.Items.Layout_Card_Panel:setVisible(false)
- end
- end
-
- function MJRoomView:setTingCardViewVisible(bVisible,tingCards)
- if true == bVisible then
- print("---------setTingCardViewVisible-----------true")
- else
- print("---------setTingCardViewVisible-----------true")
- end
- self.ui.Items.Layout_Ting_Tip_Card_Panel:setVisible(bVisible)
- self.ui.Items.ListView_Ting:removeAllItems()
- self.ui.Items.ListView_Ting:getHBar():setVisible(false)
- -- tingCards={
- -- {card=0x01},
- -- {card=0x01},
- -- {card=0x01},
- -- {card=0x01},
- -- {card=0x01},
- -- {card=0x01},
- -- {card=0x01},
- -- {card=0x01},
- -- {card=0x01},
- -- {card=0x01},
- -- {card=0x01},
- -- {card=0x01},
- -- {card=0x01},
- -- {card=0x01},
- -- {card=0x01},
- -- {card=0x01},
- -- {card=0x01},
- -- {card=0x01},
- -- {card=0x01},
- -- {card=0x01},
- -- {card=0x01},
- -- {card=0x01},
- -- {card=0x01},
- -- {card=0x01},
- -- {card=0x01},
- -- {card=0x01},
- -- {card=0x01},
- -- {card=0x01},
- -- {card=0x01},
- -- {card=0x01},
- -- {card=0x01},
- -- {card=0x01},
- -- }
- if not tingCards then return end
-
- local width=47
- local padding=8
-
- if #tingCards>=27 then
- local tingWidth=47+padding*2
- self.ui.Items.ListView_Ting:setSize(cc.size(tingWidth,self.ui.Items.ListView_Ting:getContentSize().height))
- self.ui.Items.Layout_Ting_Tip_Card_Panel:setSize(cc.size(tingWidth+83,self.ui.Items.Layout_Ting_Tip_Card_Panel:getContentSize().height))
-
- local layout=cc.Layout:create()
- local mj=cc.Sprite:createWithSpriteFrameName("mj_img_quanting.png")
- layout:addChild(mj)
- layout:setSize(cc.size(mj:getContentSize().width,self.ui.Items.ListView_Ting:getContentSize().height))
- self.ui.Items.ListView_Ting:pushBackCustomItem(layout)
- mj:setPosition(layout:getContentSize().width/2,layout:getContentSize().height/2)
- else
- local count=#tingCards>10 and 10 or #tingCards
- local tingWidth=count*47+padding*(count+1)
- self.ui.Items.ListView_Ting:setSize(cc.size(tingWidth,self.ui.Items.ListView_Ting:getContentSize().height))
- self.ui.Items.Layout_Ting_Tip_Card_Panel:setSize(cc.size(tingWidth+83,self.ui.Items.Layout_Ting_Tip_Card_Panel:getContentSize().height))
- for k,v in pairs(tingCards) do
- local layout=cc.Layout:create()
- local mj=MJ:new(v.card,MJDefine.MJType.Out,MJDefine.MyViewId)
- layout:addChild(mj)
- layout:setSize(cc.size(mj:getContentSize().width+padding,self.ui.Items.ListView_Ting:getContentSize().height))
- -- self.ui.Items.Layout_Ting_Tip_Card_Panel:addChild(mj)
- self.ui.Items.ListView_Ting:pushBackCustomItem(layout)
- mj:setPosition(layout:getContentSize().width/2,layout:getContentSize().height/2)--65)
- -- mj:setScale(0.5)
- local mjNum = cc.Text:createNode()
- mjNum:setDefaults()
- local config = mjNum:getFontConfig()
- config.fontSize = 18
- config.texColor = cc.c4b(0x98,0xcf,0x7b,255)--cc.c4b(251,213,130,255)
- mjNum:setFontConfig(config)
- layout:addChild(mjNum)
- mjNum:setPosition(cc.p(mj:getPositionX(),12))
- --mjNum:setString("x"..v.count)
- mjNum:setString(string.format("%d张", v.count))
- end
- end
- end
-
-
- --隐藏提示界面
- function MJRoomView:setGuideView(bVisible)
- self.ui.Items.Layout_tips:setVisible(bVisible)
- if bVisible then
- self.ui.Items.ImageView_3:playClip("tip")
- end
- end
-
- function MJRoomView:resetGame()
- logE("===========重置游戏数据===============")
-
- self.direcionView:setVisible(false)
- self.ui.Items.Text_CardNum:setText("")
- -- self.playerView:setOperatorTipVisible(false)
- self:setBtnSitDownVisible(false)
- self:setTingCardViewVisible(false)
- self:setChaTingCardViewVisible(false)
- self:setGuideView(false)
-
- for k,v in pairs(self.playerHandCards) do
- v:removeFromParent()
- end
- self.playerHandCards={}
-
- if self.xiaojuView then
- self.xiaojuView:removeFromParent()
- self.xiaojuView=nil
- end
-
- --隐藏工具界面 详情
- -- if self.toolView.ui.Items.ImageView_Rule_bg then
- -- self.toolView.ui.Items.ImageView_Rule_bg:setVisible(false)
- -- end
-
- --操作码
- -- self.operationLocalCode = 0
- -- self.isMoPaiOperator = false
- -- self.isGameOver = false
- -- self.isTianHu = false
- -- self.isGodHand = false
- -- --重置开招次数
- -- for i = 1,4 do
- -- -- self.playerZhao[i] = 0
- -- end
-
- end
-
-
-
- --更新房间基础数据
- function MJRoomView:updateRoomBaseData()
- --初始化背景
- -- local idx2 = tonumber(loadUserInfo("lhqgameBgPicture")) or 4
- -- self:setTableImg(idx2)
-
- --初始化方言
- -- local languageType = tonumber(loadUserInfo("lhqLanguageType")) or LHQ_GAME_LANGUAGE_TYPE.FANG_YAN
- -- setLHQCurLanguage(languageType)
-
-
- local roomInfo = app.room.roomInfo;
-
- -- 房间号
- self.ui.Items.Text_roomNum:setText("房号:"..tostring(roomInfo.nShowTableId));
-
- --局数
- self:updateGameNums()
-
- --房间玩法
- self.toolView:updateRule()
- -- local ruleAll = MJWanFa.getWanFaInfo(roomInfo.strGameInfo)--getLHQRuleStr();
- -- self.ui.Items.Text_Rule:setText(ruleAll)
- --local heght=self.ui.Items.Text_Rule:getContentSize().height+20
- --self.ui.Items.Layout_Rule:setSize(cc.size(self.ui.Items.Layout_Rule:getContentSize().width,self.ui.Items.Text_Rule:getContentSize().height))
- -- self.ui.Items.Layout_Rule:doLayout()
-
- self:onUserReadyResponse()
-
- for i = 1,4 do
- self.playerView:updatePlayerInfo(i)
- end
-
- self.toolView:updateButton()
-
- -- -- 是否显示邀请好友
- -- self:setWetChatVisible(table.nums(app.room.roomInfo.memberList) < app.room.roomInfo.nMaxPlayCount)
-
- -- if isReviewVersion() then
- -- self:setWetChatVisible(false);
- -- end
-
- -- -- 更新玩家手牌列表时,按需显示
- -- if app.room.roomInfo.nGameStartCount > 0 then
- -- self:setWetChatVisible(false)
- -- --self:setBtnSitDownVisible(false)
- -- end
- end
-
- function MJRoomView:getChangeGruopDatas(g)
- local opType=g.opType
- local showType=MJDefine.MJOperateToGroupType[g.opType]
- local opCard=g.opCard
- local opFromID = g.fromUserId
- --组合一下牌
- local group={
- opType=opType,
- showType=showType,
- values={}
- }
-
- if MJDefine.MJGroupType.Chi==showType then
- group.values={opCard,opCard+1,opCard+2}
- elseif MJDefine.MJGroupType.Peng==showType then
- group.values={opCard,opCard,opCard}
- else
- group.values={opCard,opCard,opCard,opCard}
- end
- if opFromID then
- group.fromViewId = app.room:getViewIdByUserId(opFromID)
- end
- return group
- end
-
-
- function MJRoomView:onGameReconnection()
- -- logD("LHQ当前版本号:"..getLHQCurVersion())
- --更新房间基础数据
- local roomInfo = app.room.roomInfo;
- self:updateRoomBaseData()
-
- -- self:updateAllGpsInfo()
- -- self:checkGpsDistance(nil,roomInfo.nGameStartCount==0)
- -- self:checkMyGpsNeedUpdate();
- self.toolView:updateButton()
-
-
- --显示离线状态
- for k,v in pairs(roomInfo.memberList) do
- local viewId = app.room:getViewIdByUserId(k)
- local nOffLineState = v.nOnlineStatus
- self.playerView:setPlayerOffLineVisible(nOffLineState ~= MJDefine.PlayerOnlineStatus.Online,viewId)
- end
-
- --断线重连
- if roomInfo.nGameStartCount > 0 then
-
- if self._fastRequestView then
- self._fastRequestView:removeSelf()
- self._fastRequestView = nil
- end
-
- local function runOnGameReconnection(onEnd)
- --隐藏俱乐部
- self:hideClub()
-
- local myUserId = app.room:getMyUserId()
-
- local memberStatus ={}
- local dismissUserId=0
- for k,v in pairs(roomInfo.memberList) do
- local viewId = app.room:getViewIdByUserId(k)
- local nOffLineState = v.nOnlineStatus
- --显示离线
- self.playerView:setPlayerOffLineVisible(nOffLineState ~= MJDefine.PlayerOnlineStatus.Online,viewId)
-
-
- --发起解散状态的ID
- if v.nDisbandStatus == 1 then
- dismissUserId=v.nUserId
- end
-
- if v.nDisbandStatus ~= 0 then
- table.insert(memberStatus,{userId = v.nUserId , status = v.nDisbandStatus})
- end
- end
-
-
- --显示解散界面
- if roomInfo.bUserDisbandGame==1 and dismissUserId~=0 and roomInfo.isGameOver~=1 then
- local view = require("luaScript.Views.Room.RoomDismissView"):new(dismissUserId,roomInfo.memberList,roomInfo.nDismissStateTime)--MJRoomDismissView:new(dismissUserId)
- -- view:setAnchorPoint(cc.p(0.5, 0.5))
- self:addChild(view,1)
-
- app.room:dispatchEvent({name = GAME_EVENT.DISSMISS_UPDATE_STATUS , memberStatus = memberStatus})
- -- app:showWaitDialog(view)
- end
-
-
- --如果一局结束,玩家点了准备,不再显示牌信息
- if MJDefine.GameStatus.GAME_STATUS_ROUND_OVER == roomInfo.nStatus and roomInfo.memberList[myUserId].nPlayerFlag == 1
- or MJDefine.GameStatus.GAME_STATUS_GAME_OVER == roomInfo.nStatus and roomInfo.memberList[myUserId].nPlayerFlag == 1
- then --游戏为停止或开始状态
-
- self:onUserReadyResponse({nUserId=myUserId})
- if onEnd then
- onEnd()
- end
- return
- end
-
- self:updateBanker()
-
- self:initHandCardNodes()
- --初始化方位
- self.direcionView:initDirection(self.desktopType)
- self.direcionView:updateDirection(roomInfo.outCardSeatId)
-
- --显示用户的牌
- for userId,v in pairs(roomInfo.memberList) do
- local viewId = app.room:getViewIdByUserId(userId)
- if self.playerHandCards[viewId] then
- -- logE(v.handCards)
- --组合一下牌
- local groups={}
- if v.gruoupCards then
- for _,group in pairs(v.gruoupCards) do
- table.insert(groups,self:getChangeGruopDatas(group))
- end
- end
- self.playerHandCards[viewId]:createGroupCards(groups)
- self.playerHandCards[viewId]:createOutCards(v.outCards)
- self.playerHandCards[viewId]:createHandCards(v.handCards)
- if userId == myUserId then
- self.playerHandCards[viewId]:resetHandCards()
- --显示听
- if v.nTingStatus==MJDefine.MJTingStatus.Ting then
- self:setChaTingCardViewVisible(true)
- end
- --设置可以出牌
- --[[if roomInfo.isNeedOutCard==MJDefine.NeedOutCard.Need then
- self.playerHandCards[viewId]:setOutCardEnable(true)
- end --]]
- end
-
-
- if roomInfo.needOutCardId == userId then
- if userId == myUserId and roomInfo.lastOpCard~=0 then
- self.playerHandCards[viewId]:removeHandCard(roomInfo.lastOpCard)
- self.playerHandCards[viewId]:resetHandCards()
- self.playerHandCards[viewId]:createHandCards(roomInfo.lastOpCard)
- end
-
- self.playerHandCards[viewId]:setOutCardEnable(true)
- end
- end
- end
-
- --显示出牌角标
- local lastOutCardViewId = app.room:getViewIdByUserId(roomInfo.lastOutCardId)
- app.room:dispatchEvent({name = MJDefine.MJEvent.OutCardFalg,value=roomInfo.lastOutCard,viewId=lastOutCardViewId})
-
- --设置可以出牌的人
- -- local outCardViewId = app.room:getViewIdBySeatId(roomInfo.outCardSeatId)
- -- if outCardViewId then
- -- if (outCardViewId~=MJDefine.MyViewId and roomInfo.lastOpCard==0) or (outCardViewId == MJDefine.MyViewId or roomInfo.isNeedOutCard) then
- -- self.playerHandCards[outCardViewId]:setOutCardEnable(true)
- -- end
- -- end
-
- --显示听标示
- app.room:dispatchEvent({name = MJDefine.MJEvent.PushTing})
-
- --如果有操作显示操作按钮
- self.playerHandCards[MJDefine.MyViewId]:showOperate(roomInfo.operates,roomInfo.lastOpCard)
-
-
- --显示结算界面
- if roomInfo.nStatus==MJDefine.GameStatus.GAME_STATUS_ROUND_OVER or roomInfo.nStatus==MJDefine.GameStatus.GAME_STATUS_GAME_OVER then
- self:showOpenCard()
- self:showXiaoJuView()
- -- for k,v in pairs(roomInfo.memberList) do
- -- local viewId = app.room:getViewIdByUserId(v.nUserId)
- -- if viewId==MJDefine.MyViewId then
- -- --我自己则屏蔽触摸事件
- -- self.playerHandCards[viewId]:removeTouchEvent()
- -- else
- -- --显示所有底牌
- -- self.playerHandCards[viewId]:removeAllHandCards()
- -- self.playerHandCards[viewId]:createOpenHandCards(v.handCards)
- -- end
- -- end
-
- -- -- self:onGameXiaoJuResponse()
- -- self.xiaojuView = MJRoomXiaoJuView:new(roomInfo.isGameOver)
- -- self:addChild(self.xiaojuView)
- end
-
- self:setBtnSitDownVisible(false)
-
-
- if onEnd then
- onEnd()
- end
- end
- log("2000000000-MJRoomView - self:addCallBack(runOnGameReconnection)" )
- self:addCallBack(runOnGameReconnection)
- else
- -- 游戏未开始
- if roomInfo.nStatus and roomInfo.nStatus<MJDefine.GameStatus.GAME_STATUS_WAIT_BANKER_START then
- --self.toolView:enableHosting(false)
- local quickStartInfo = roomInfo.quickStartInfo
- if quickStartInfo then
- if quickStartInfo.tablefaststate == 1 then
- local tmpInfo = {}
- for uid,status in pairs(quickStartInfo.list) do
- table.insert(tmpInfo, {nUserId=tonumber(uid), nStatus = status})
- end
- local response = {}
- response.pList = tmpInfo
- response.timeOut = roomInfo.quickStartInfo.time
- self:onBroadcastFaststart({response=response})
- else
- --self.toolView:showFastStart(true)
- end
- else
- if self._fastRequestView then
- self._fastRequestView:removeSelf()
- self._fastRequestView = nil
- end
- --self.toolView:showFastStart(true)
- end
- end
- end
- end
-
-
- function MJRoomView:onClickReady()
- self.ui:sendMsg(app.room, MJDefine.MJEvent.CallReadyRequest)
- playVoice("res/sound/room/sit.ogg")
- self.isTouchCurScene = true
- end
-
- -- 邀请好友
- function MJRoomView:onClickFriends()
- playBtnEffect()
- local tt =
- {
- [0] = "零缺四",
- [1] = "一缺三",
- [2] = "二缺二",
- [3] = "三缺一",
- [4] = "满座",
- }
-
- if app.room:getMaxPlayerCount()==3 then
- tt =
- {
- [0] = "零缺三",
- [1] = "一缺二",
- [2] = "二缺一",
- [3] = "满座",
- }
- end
-
- local num = table.nums(app.room.roomInfo.memberList)
- local strNum = tt[num]
- --根据游戏类型分享
- local roomInfo = app.room.roomInfo;
- local jsonInfo = json.decode(roomInfo.strGameInfo)
-
- local mjName=getSubGameConfig(app.gameId).gameName or "麻将"
-
- local title = string.format("%s 房号[%s] %s", mjName ,app.room.roomInfo.nShowTableId,strNum) --LHQ_GAME_CONST_WANFA[jsonInfo.gamerule]
-
- --添加俱乐部ID
- if app.club_php.clubID and app.club_php.clubID ~= 0 then
- title = string.format("%s %sID[%d]", title,PLN.CLUB_NAME, tonumber(app.club_php.clubID))
- end
-
- local strGameNum = string.format("%s局", app.room.roomInfo.nTotalGameNum)
-
- local strGameMode = MJWanFa.getWanFaInfo(app.room.roomInfo.strGameInfo)--getLHQRuleStr()
-
- local strNames = ""
- local index = 0
- for k,v in pairs(app.room.roomInfo.memberList) do
- index = index + 1
- local userInfo = json.decode(v.userInfo)
- local name = getSubStringNickname(userInfo.nickname)
- strNames = strNames..name
- if index < num then
- strNames = strNames..","
- end
- end
- local desc = string.format("%s,%s 玩家:%s", strGameNum, strGameMode, strNames)
- print(desc)
-
- local imagePath = cc.FileUtils:getInstance():getWritablePath().."icon.png"
-
- local info = {}
- info.scene = "talk"
- info.contentType = "url"
- info.url = app.config.Setting.appDownloadUrl
- info.title = title
- info.description = desc
- info.image = imagePath
- info.imageWidth = 100
-
- app.plugin:shareGame(info)
- end
-
- -- 邀请好友
- function MJRoomView:onClickFriends2()
- playBtnEffect()
- local tt = {
- [0] = "零缺四",
- [1] = "一缺三",
- [2] = "二缺二",
- [3] = "三缺一",
- [4] = "满座",
- }
-
- if app.room.roomInfo.nMaxPlayCount==3 then
- tt = {
- [0] = "零缺三",
- [1] = "一缺二",
- [2] = "二缺一",
- [3] = "满座",
- }
- end
-
- if app.room.roomInfo.nMaxPlayCount==2 then
- tt = {
- [0] = "零缺二",
- [1] = "一缺一",
- [2] = "满座",
- }
- end
-
- local num = table.nums(app.room.roomInfo.memberList)
- local strNum = tt[num]
- --根据游戏类型分享
- local roomInfo = app.room.roomInfo
- local jsonInfo = json.decode(roomInfo.strGameInfo)
-
- local mjName=getSubGameConfig(app.gameId).gameName or "麻将"
- local strGameNum = string.format("%s局", app.room.roomInfo.nTotalGameNum)
- local title = string.format("%s 房号[%s] %s %s", mjName ,app.room.roomInfo.nShowTableId, strNum, strGameNum) --LHQ_GAME_CONST_WANFA[jsonInfo.gamerule]
- --添加俱乐部ID
- if app.club_php.clubID and app.club_php.clubID ~= 0 then
- title = string.format("%s 亲友圈ID[%d]", title, tonumber(app.club_php.clubID))
- end
-
- local strGameMode = MJWanFa.getWanFaInfo(roomInfo.strGameInfo)--getLHQRuleStr()
- local strNames = ""
- local index = 0
- for k,v in pairs(app.room.roomInfo.memberList) do
- index = index + 1
- local userInfo = json.decode(v.userInfo)
- local name = getSubStringNickname(userInfo.nickname)
- strNames = strNames..name
- if index < num then
- strNames = strNames..","
- end
- end
- local desc = string.format("%s \n玩家:%s",strGameMode, strNames)
- print(desc)
-
- local info = {}
- info.title = title
- info.description = desc
- info.copyData={type=2}
-
- local view = import("luaScript.Views.Main.ShareView"):new(info)
- view:setAnchorPoint(cc.p(0.5, 0.5))
- app:showWaitDialog(view)
- end
-
- --隐藏微信按钮
- function MJRoomView:setWetChatVisible(bVisible)
- -- self.toolView.ui.Items.btnInvite:setVisible(bVisible)
- -- self.ui.Items.Button_Invite:setVisible(bVisible)
- -- if app.room and app.room.roomInfo and table.nums(app.room.roomInfo.memberList) == 4 then
- -- self.toolView.ui.Items.Button_Ready:setPositionX(640)
- -- self.ui.Items.Button_Invite:setPositionX(640)
- -- end
- -- self:setInviteClubVisible(bVisible)
- -- self:updateButtonPosition()
- end
-
- --隐藏准备按钮
- function MJRoomView:setBtnSitDownVisible(bVisible)
- -- self.toolView.ui.Items.Button_Ready:setVisible(bVisible)
- --self.ui.Items.Button_Ready:setVisible(bVisible)
- -- self:updateButtonPosition()
- end
-
- --设置邀请亲友圈成员显示
- function MJRoomView:setInviteClubVisible(bVisible)
- if self.ui.Items.Button_Invite_Club then
- if app.club_php.clubID and app.club_php.clubID ~= 0 then
- self.ui.Items.Button_Invite_Club:setVisible(bVisible)
- else
- self.ui.Items.Button_Invite_Club:setVisible(false)
- end
- end
- end
-
-
-
- function MJRoomView:showStateText()
- --游戏没开始状态
- if app.room.roomInfo.nGameStartCount <= 0 then
- local myUserId = app.room:getMyUserId()
- if app.room.roomInfo.nStartGameUid == myUserId then
- self.ui.Items.stateText:setText("等待其他玩家加入...");
- self.ui.Items.stateTextTime:setText("");
- else
- local memberInfo = app.room.roomInfo.memberList[app.room.roomInfo.nStartGameUid]
- if memberInfo then
- local userInfo = json.decode(memberInfo.userInfo)
- if not userInfo then
- return
- end
- -- 玩家名字
- local nickname = userInfo.nickname
- local intro = string.format("等待%s开始游戏",nickname)
- self.ui.Items.stateTextTime:setText("");
- self.ui.Items.stateText:setText(intro)
- end
- end
- end
- end
-
- function MJRoomView:onGameSendCardResponse()
- local function runGameSendCardResponse(onEnd)
- log("2000000000-MJRoomView - runGameSendCardResponse()" )
- -- if self.taiPaiTimer then
- -- cc.Director:getInstance():getScheduler():unscheduleScriptEntry(self.taiPaiTimer)
- -- end
-
- --显示指示器
- -- local bankerViewId = app.room:getViewIdBySeatId(app.room.roomInfo.nBankSeatId)
- -- self:setCircleCardLeftPanelView(true,bankerViewId,19)
-
- --发牌
- -- self:createCard(true,app.user.loginInfo.uid,onEnd)
-
- -- print("ding piao:"..table.tostring(app.room.roomInfo.memberList))
-
- --[[for k,v in pairs(app.room.roomInfo.memberList) do
- local viewId = app.room:getViewIdByUserId(v.nUserId)
- if self.playerHandCards[viewId] then
- self.playerHandCards[viewId]:createHandCards(v.handCards)
- self.playerHandCards[viewId]:resetHandCards()
- end
- end
- --]]
-
- local myUserId = app.room:getMyUserId()
- for k,v in pairs(app.room.roomInfo.memberList) do
- local viewId = app.room:getViewIdByUserId(v.nUserId)
- if self.playerHandCards[viewId] then
- self.playerHandCards[viewId]:createHandCards(v.handCards)
- self.playerHandCards[viewId]:resetHandCards()
- end
-
- if v.isBaoPai == 1 and myUserId == v.nUserId then
- self.playerHandCards[viewId]:showBaoPai()
- end
- end
-
- local effect=MJAnimationCompnent.CreateGameStart()
- self.ui.Items.Layout_Player:addChild(effect,5)
- -- MJSound.PlayStartGame()
-
- MJAnimationCompnent.CreateStartSendCards(self.playerHandCards,onEnd)
-
- -- if onEnd then
- -- onEnd()
- -- end
- end
- log("2000000000-MJRoomView - addCallBack(runGameSendCardResponse)" )
- self:addCallBack(runGameSendCardResponse);
- end
-
-
- -- 广播桌子上所有玩家庄家起手操作
- function MJRoomView:onBankerOutCard(data)
-
- --[[ -- 庄家uid
- , defVar("nUserId", VT_Int, 0)
- -- 庄家操作类型
- , defVar("mainOpCode", VT_Short, 0)
- --庄家是否需要出牌0不需要 1:需要
- , defVar("IsShouldOutCard", VT_UChar, 0)--]]
- local function runOnBankerOutCard(onEnd)
- -- log("2000000000-MJRoomView - (runOnBankerOutCard)")
- -- logE("name = ", data.name)
- logE("onBankerOutCard :"..table.tostring(data.response))
- -- if not data.response.nUserId then
- -- showTooltip("庄家起手操作nUserId is not exist")
- -- end
- local viewId = app.room:getViewIdByUserId(data.response.nUserId)
- local card= data.response.card
- local operates=data.response.operates
- local nSeatId=data.response.nSeatId
-
- if self.playerHandCards[viewId] then
- self.playerHandCards[viewId]:onGetCard(operates,card)
- end
-
-
- self.playerHandCards[MJDefine.MyViewId]:showOperate(operates,card)
-
- self:updateGameNums()
-
- self.direcionView:updateDirection(nSeatId)
-
-
- if onEnd then
- onEnd()
- end
- end
-
- log("2000000000-MJRoomView - addCallBack(runOnBankerOutCard)")
- self:addCallBack(runOnBankerOutCard);
-
- end
-
- function MJRoomView:onQiangGangHu(data)
-
- --[[ -- 庄家uid
- , defVar("nUserId", VT_Int, 0)
- -- 庄家操作类型
- , defVar("mainOpCode", VT_Short, 0)
- --庄家是否需要出牌0不需要 1:需要
- , defVar("IsShouldOutCard", VT_UChar, 0)--]]
- local function runOnQiangGangHu(onEnd)
- -- log("2000000000-MJRoomView - (runOnBankerOutCard)")
- -- logE("name = ", data.name)
- logE("runOnQiangGangHu :"..table.tostring(data.response))
- -- if not data.response.nUserId then
- -- showTooltip("庄家起手操作nUserId is not exist")
- -- end
- -- local viewId = app.room:getViewIdByUserId(data.response.nUserId)
- local opType=data.response.opType
- local opCard= data.response.opCard
-
- local outCardSuccess=MJMessage.OutCardSuccess:new()
-
- -- local operates=VT_Vector(MJMessage.OperateCard)
-
- local operate=MJMessage.OperateCard:new()
- operate.opType=opType
- operate.opCard=opCard
- table.insert(outCardSuccess.operates.Datas,operate)
-
- self.playerHandCards[MJDefine.MyViewId]:showOperate(outCardSuccess.operates,opCard)
-
-
- -- local operates=data.response.operates
- -- local nSeatId=data.response.nSeatId
-
- -- if self.playerHandCards[viewId] then
- -- self.playerHandCards[viewId]:onGetCard(operates,card)
- -- end
-
-
- -- self.playerHandCards[MJDefine.MyViewId]:showOperate(operates,card)
-
- -- self:updateGameNums()
-
- -- self.direcionView:updateDirection(nSeatId)
-
-
- if onEnd then
- onEnd()
- end
- end
-
- log("2000000000-MJRoomView - addCallBack(runOnQiangGangHu)")
- self:addCallBack(runOnQiangGangHu);
-
- end
-
-
- --出牌错误
- function MJRoomView:onOutCardError(data)
- local function runOnOutCardError(onEnd)
- logE("MJRoomView:onOutCardError(), response = ", table.tostring(data.response))
- log("2000000000-MJRoomView - runOnOutCardError")
- --出牌错误主动上报日志
- uploadLogs(GAME_ERROR_TYPE.AUTO)
- -- --隐藏出牌效果
- -- self:setOutCardVisible(false)
- -- --恢复出的那张牌的透明度
- -- local index = self.ui.Items.ImageView_handTempCard.index
- -- self.handCardItem[index]:setOpacity(255)
- -- self.bOutCard = true
- self:requestReconnect();
-
- if onEnd then
- onEnd()
- end
- end
- log("2000000000-MJRoomView - addCallBack(runOnOutCardError)")
- self:addCallBack(runOnOutCardError)
-
- end
-
-
- function MJRoomView:onOutCard(data)
- local function runOnOutCard(onEnd)
- logE("MJRoomView:runOnOutCard(), response = ", table.tostring(data.response))
- log("2000000000-MJRoomView - runOnOutCard")
-
- -- local viewId = app.room:getViewIdByUserId(data.response.nUserId)
- -- local card= data.response.card
- -- if self.playerHandCards[viewId] then
- -- self.playerHandCards[viewId]:createOutCards(card)
- -- end
-
- if onEnd then
- onEnd()
- end
- end
-
- log("2000000000-MJRoomView - addCallBack(runOnOutCard)")
- self:addCallBack(runOnOutCard)
- end
-
-
- function MJRoomView:onTurnOutCard(data)
- local function runOnTurnOutCard(onEnd)
- logE("MJRoomView:runOnOutCard(), response = ", table.tostring(data.response))
- log("2000000000-MJRoomView - runOnOutCard")
-
-
- self.playerHandCards[MJDefine.MyViewId]:setOutCardEnable(true)
- -- local viewId = app.room:getViewIdByUserId(data.response.nUserId)
- -- local card= data.response.card
- -- if self.playerHandCards[viewId] then
- -- self.playerHandCards[viewId]:createOutCards(card)
- -- end
-
- if onEnd then
- onEnd()
- end
- end
-
- log("2000000000-MJRoomView - addCallBack(runOnTurnOutCard)")
- self:addCallBack(runOnTurnOutCard)
- end
-
-
-
- --出牌成功
- function MJRoomView:onOutCardSuccess(data)
- logE("MJRoomView:onOutCardSuccess(), response = ", table.tostring(data.response))
- --[[
- -- 出牌用户id
- , defVar("nOutCardUserId", VT_Int, -1)
- -- 出的牌
- , defVar("byOutCard", VT_UChar, -1)
- -- 可以的操作ma
- , defVar("mainOpCode", VT_Short, -1)
- -- 玩家操作
- , defVar("operations", VT_Vector(ChuPaiPlayerOperation), {})--]]
- --local function runOnOutCardSuccess(onEnd)
- log("2000000000-MJRoomView - runOnOutCardSuccess---------")
-
- local viewId = app.room:getViewIdByUserId(data.response.nUserId)
- local card= data.response.card
- local operates=data.response.operates
- --local typr = operates.opType
-
- local function callback()
- self.playerHandCards[MJDefine.MyViewId]:showOperate(operates,card)
- if onEnd then
- onEnd()
- end
- end
-
- if self.playerHandCards[viewId] then
- self.playerHandCards[viewId]:onOutCard(card,callback)--onOutCard(data.response,true)
- app.room:dispatchEvent({name = MJDefine.MJEvent.OutCardFalg, value=card ,viewId=viewId})
- else
- callback()
- end
-
- --end
- log("2000000000-MJRoomView - addCallBack(runOnOutCardSuccess)")
- --self:addCallBack(runOnOutCardSuccess)
- end
-
- --用户行为提示
- function MJRoomView:showOperatorTip(viewId,mType)
-
- local tip = self.allNodes[viewId].tip
- tip:setVisible(true)
-
- local nUserID = app.room:getUserIdByViewId(viewId)
- playLHQVoiceOperation(mType,nUserID)
-
- --[[if mType == LHQ_OP_TYPE.OP_TYPE_CANCEL then
- tip:loadTextureFromPlist(LHQ_TIP_FILE.GUO)
- --tip:setVisible(false)
- elseif mType == LHQ_OP_TYPE.OP_TYPE_CHI then
- tip:loadTextureFromPlist(LHQ_TIP_FILE.CHI)
- elseif mType == LHQ_OP_TYPE.OP_TYPE_BI then
- tip:loadTextureFromPlist(LHQ_TIP_FILE.BIPAI)
- elseif mType == LHQ_OP_TYPE.OP_TYPE_PENG then
- tip:loadTextureFromPlist(LHQ_TIP_FILE.PENG)
- elseif mType == LHQ_OP_TYPE.OP_TYPE_MINGWEI then
- tip:loadTextureFromPlist(LHQ_TIP_FILE.MINGWEI)
- elseif mType == LHQ_OP_TYPE.OP_TYPE_ANWEI then
- tip:loadTextureFromPlist(LHQ_TIP_FILE.ANWEI)
- elseif mType == LHQ_OP_TYPE.OP_TYPE_PAO then
- tip:loadTextureFromPlist(LHQ_TIP_FILE.PAO)
- elseif mType == LHQ_OP_TYPE.OP_TYPE_CHONG_PAO then
- tip:loadTextureFromPlist(LHQ_TIP_FILE.CHONGPAO)
- elseif mType == LHQ_OP_TYPE.OP_TYPE_TI then
- tip:loadTextureFromPlist(LHQ_TIP_FILE.TI)
- elseif mType == LHQ_OP_TYPE.OP_TYPE_HU then
- tip:loadTextureFromPlist(LHQ_TIP_FILE.HU)
- tip:setVisible(false)
- end
-
-
-
- tip:setScale(3.0)
- local seq = cc.Sequence:create(cc.ScaleTo:create(0.2,1),cc.DelayTime:create(0.3),cc.CallFunc:create(function ()
- tip:setVisible(false)
- end))
- tip:runAction(seq)--]]
-
- end
-
-
- --操作错误
- function MJRoomView:onOperationError(data)
- local function runOnOperationError(onEnd)
- log("2000000000-MJRoomView - (runOnOperationError)")
- --恢复操作面板
- -- self:touchEatOneCardCallBack()
-
- if onEnd then
- onEnd()
- end
- end
- log("2000000000-MJRoomView - addCallBack(runOnOperationError)")
-
- self:addCallBack(runOnOperationError)
- end
-
-
- -- 先操作玩家
- function MJRoomView:onOperationFirst(data)
- local function runOnOperationFirst(onEnd)
- log("2000000000-MJRoomView - (runOnOperationFirst)")
-
- local nUserId = data.response.nUserId
-
- local viewId = app.room:getViewIdByUserId(nUserId)
- if viewId == self:getMeViewId() then
- --隐藏出牌面板
- self:setOperatorPanelView(false,nil)
- --隐藏吃牌面板
- self:setEatCardView(false)
- end
-
- if onEnd then
- onEnd()
- end
- end
- log("2000000000-MJRoomView - addCallBack(runOnOperationFirst)")
-
- self:addCallBack(runOnOperationFirst)
- end
-
- -- 操作成功
- function MJRoomView:onOperationCodeSuccess(data)
- --[[
- -- 操作者的id
- , defVar("nUserId", VT_Int, -1)
- -- 牌类型
- , defVar("opType", VT_Short, 0)
- -- 操作的牌
- , defVar("opCard", VT_UChar, 0)
- -- -- 操作的牌(只有天胡时 opCard才为0)
- -- , defVar("card", VT_UChar, 0)
- -- 表明操作者他是否要出牌
- , defVar("isNeedOutCard", VT_UChar, 0)
-
- -- 被操作者座位Id
- , defVar("formSeatId", VT_UChar, -1)
- ]]
- local function runOnOperationSuccess(onEnd)
- log("2000000000-MJRoomView - (runOnOperationSuccess)")
- logE("MJRoomView:onOperationCodeSuccess :"..table.tostring(data.response))
- local response = data.response
- local nUserId = response.nUserId
- local opType = response.opType
- local opCard = response.opCard
- local bIsOutCard = response.isNeedOutCard > 0
- local fromSeatId = response.fromSeatId
-
- local viewId = app.room:getViewIdByUserId(nUserId)
- local fromViewId=app.room:getViewIdBySeatId(fromSeatId)
-
- if self.playerHandCards[viewId] then
- --组合一下牌
- local groups={
- self:getChangeGruopDatas({opType=opType,opCard=opCard})
- }
- --删除手中对应的牌
- local deleteCards
- for k,v in pairs(groups) do
- if v.showType==MJDefine.MJGroupType.Peng then
- -- deleteCards={
- -- {card=opCard},
- -- {card=opCard},
- -- }
- self.playerHandCards[viewId]:removeHandCardByNum(opCard,2)
- elseif v.showType==MJDefine.MJGroupType.Chi then
- --TODO:吃的牌怎么删除
- elseif v.showType==MJDefine.MJGroupType.AnGang then
- -- deleteCards={
- -- {card=opCard},
- -- {card=opCard},
- -- {card=opCard},
- -- {card=opCard},
- -- }
- self.playerHandCards[viewId]:removeHandCardByNum(opCard,4)
- else
- if opType==MJDefine.MJOperateType.OPREATE_BAGANG then
- self.playerHandCards[viewId]:removeHandCardByNum(opCard,1)
- else
- self.playerHandCards[viewId]:removeHandCardByNum(opCard,3)
- end
- -- deleteCards={
- -- {card=opCard},
- -- {card=opCard},
- -- {card=opCard},
- -- }
- end
- end
- -- if deleteCards then
- -- self.playerHandCards[viewId]:removeHandCard(deleteCards)
- -- end
-
- --删除出去的牌 遍历哪些操作需要删除牌
- for k,v in pairs(MJDefine.MJOperateNeedRemoveCard) do
- if v==opType then
- self.playerHandCards[fromViewId]:removeOutCard(opCard)
- break
- end
- end
-
- if opType==MJDefine.MJOperateType.OPREATE_BAGANG then
- self.playerHandCards[viewId]:buGang(opCard)
- else
- self.playerHandCards[viewId]:createGroupCards(groups,fromViewId)
- end
-
- self.playerHandCards[viewId]:resetHandCards()
- self.playerHandCards[viewId]:hideOperate()
- self.playerHandCards[viewId]:setOutCardEnable(bIsOutCard)
-
- self.direcionView:updateDirection(app.room:getSeatIdByViewId(viewId))
- end
-
- --播放动画
- local effect=MJAnimationCompnent.CreateOperareEffect(opType,onEnd)
- if effect then
- self.ui.Items.Layout_Player:addChild(effect)
- effect:setLocalZOrder(1000)
- effect:setPosition(self.playerHandCards[viewId]:getAnimationPostion())
- else
- if onEnd then
- onEnd()
- end
- end
-
- --音效
- local userInfo=app.room:getUserInfo(nUserId)
- if userInfo then
- MJSound.PlayOperateSound(userInfo.sex,opType)
- end
-
- --删除等待操作的显示
- if self.waitOperates and #self.waitOperates>0 then
- for k,v in pairs(self.waitOperates) do
- v:removeFromParent()
- end
- self.waitOperates={}
- end
- -- sprite:setPosition(640,360)
- -- if onEnd then
- -- onEnd()
- -- end
- end
- log("2000000000-MJRoomView - addCallBack(runOnOperationSuccess)")
-
- self:addCallBack(runOnOperationSuccess)
-
- end
-
-
- -- function MJRoomView:addCallBack(callback)
- -- table.insert(self.callbackQueue, callback)
- -- logE(" #self.callbackQueue:".. #self.callbackQueue)
- -- --高延迟情况下,执行快速播放,15条是没有标准,根据实际调整的
- -- --if #self.callbackQueue >= 15 then
- -- --cc.Director:getInstance():getScheduler():setTimeScale(5.0)
- -- --else
- -- cc.Director:getInstance():getScheduler():setTimeScale(1.0)
- -- --end
- -- local function runFunc()
-
- -- log("2000000000 - runNextFunc() size = ", #self.callbackQueue )
-
- -- if #self.callbackQueue <= 0 then
- -- self.callbackRunning = false
- -- return
- -- end
-
- -- --logE("2000000001 - ", debug.traceback())
-
- -- local func = self.callbackQueue[1]
- -- table.remove(self.callbackQueue,1)
- -- self.callbackRunning = true
- -- func(function()
- -- self.callbackRunning = false;
- -- runFunc();
- -- end)
- -- end
- -- log("self.callbackRunning:",self.callbackRunning)
- -- if not self.callbackRunning then
- -- runFunc();
- -- end
- -- end
-
- -- 添加延迟回调事件,delay不传默认为0,但是需注意,排在有delay的后面事件,也会相应的跟着一起间隔
- function MJRoomView:addCallBack(callback, delay)
- local callbackInfo = {
- callback = callback,
- delay = delay or 0
- }
-
- -- 将回调放在一起管理
- table.insert(self.callbackQueue, callbackInfo)
- logE(" #self.callbackQueue:".. #self.callbackQueue)
- cc.Director:getInstance():getScheduler():setTimeScale(1.0)
-
- local function runFunc()
- if #self.callbackQueue <= 0 then
- self.callbackRunning = false
- return
- end
- local callbackInfo = self.callbackQueue[1]
- local func = callbackInfo.callback;
- local delay = callbackInfo.delay;
- table.remove(self.callbackQueue,1) -- 执行一个则删除一个回调
- self.callbackRunning = true
-
- local function runCallback (cb)
- cb(function()
- self.callbackRunning = false;
- runFunc(); -- 然后继续执行下一个回调
- end)
- end
-
- -- 如果有delay,那么启动全局定时器
- if delay and delay > 0 then
- local entryId = nil;
- entryId = cc.Director:getInstance():getScheduler():scheduleScriptFunc(function()
- runCallback(func);
- if entryId then
- cc.Director:getInstance():getScheduler():unscheduleScriptEntry(entryId);
- end
- end, delay, false);
- else
- runCallback(func);
- end
- end
- log("self.callbackRunning:",self.callbackRunning)
- if not self.callbackRunning then
- runFunc();
- end
- end
-
- -- 其他玩家坐下成功
- function MJRoomView:onOtherSitDownResponse(data)
- if not data or not data.nSeatShowId then
- return
- end
-
- -- local nSeatShowId = data.nSeatShowId;
- -- local nUserId = app.room:getUserIdByViewId(nSeatShowId)
- -- self:checkGpsDistance(nUserId,true);
-
- self:onUserReadyResponse()
- -- 是否显示邀请好友
- self.toolView:updateButton()
- end
-
- function MJRoomView:onOtherLogoutResponse(data)
- local jushu = app.room.roomInfo.nGameStartCount or 0
- if (not data or not data.nUserId or not data.nSeatShowId) or jushu > 0 then
- return
- end
-
-
- local function test(onEnd)
- -- local memberList = app.room.roomInfo.memberList
- -- memberList[data.nUserId] = nil
-
- self.playerView:updatePlayerInfo(data.nSeatShowId)
- self:onUserReadyResponse()
-
- --更新GPS
- -- self:updateAllGpsInfo()
- -- self:checkGpsDistance()
-
- self.toolView:updateButton()
-
- if self._fastRequestView then
- self._fastRequestView:removeSelf()
- self._fastRequestView = nil
- end
-
- logE("88888-onOtherLogoutResponse onEnd")
- if onEnd then
- onEnd()
- end
- end
- self:addCallBack(test)
- end
-
- function MJRoomView:updateGameNums()
- -- 更新当前局数
- -- local roomInfo = app.room.roomInfo
- -- local curCount = roomInfo.nGameStartCount or 0
- -- local str = string.format("局数%d/%d", curCount, roomInfo.nTotalGameNum)
- -- self.ui.Items.Text_JuShu:setText(str)
-
- --更新牌数
- -- self.ui.Items.Text_CardNum:setText(roomInfo.nLeaveCardNum or 0)
- -- if curCount>0 then
- -- self.ui.Items.ImageView_CardNum:setVisible(false)
- -- self.ui.Items.Layout_GameInfo:setVisible(true)
- -- else
- -- self.ui.Items.ImageView_CardNum:setVisible(false)
- -- self.ui.Items.Layout_GameInfo:setVisible(false)
- -- end
-
- if self.direcionView then
- self.direcionView:updateGameNums()
- end
- end
-
- -- 游戏开始
- function MJRoomView:onGameStartResponse()
-
- local function runGameStartResponse(onEnd)
- log("2000000000-MJRoomView - runGameStartResponse()" )
-
- --更新背景
- self:changeGameBg(true)
-
- --隐藏俱乐部
- self:hideClub()
-
- --重置玩家数据
- self:resetGame()
-
- self:initHandCardNodes()
-
- --写入数据
- for k,v in pairs(app.room.roomInfo.memberList) do
- v.nPlayerFlag = 2
- end
-
- --更新玩家状态状态
- self:onUserReadyResponse()
-
- self.toolView:updateButton()
- -- 隐藏邀请好友
- -- self:setWetChatVisible(false)
-
- -- 更新局数
- self:updateGameNums()
-
- --更新庄家
- self:updateBanker()
-
- --初始化方位
- self.direcionView:initDirection(self.desktopType)
- self.direcionView:updateDirection(app.room.roomInfo.nBankSeatId)
-
- --展示洗牌
- local isHaveCallBack = false
- local function call()
- if not isHaveCallBack then
- isHaveCallBack = true
- logD("only one shuffle!!")
- if onEnd then
- onEnd()
- end
- end
- end
- local isFind = self:isHavePlayerShuffle()
- if isFind then
- for k,v in pairs(app.room.roomInfo.shuffleList) do
- local viewId = app.room:getViewIdByUserId(v.nUserId)
- if v.bShuffle == 1 and self.playerHandCards[viewId] then
- local viewId = app.room:getViewIdByUserId(v.nUserId)
- if v.bShuffle == 1 and self.playerHandCards[viewId] then
- MJAnimationCompnent.CreateXiPai(self.ui.Items.Layout_Player,MJDefine.MJXiPaiConfig[viewId].position,call,viewId)
- end
-
- --[[ local effect = MJAnimationCompnent.CreateXiPai()
- if effect then
- self.ui.Items.Layout_Player:addChild(effect)
- effect:setLocalZOrder(1000)
- effect:setEulerRotation(MJDefine.MJXiPaiConfig[viewId].angle)
- effect:setPosition(self.playerHandCards[viewId]:getAnimationPostion())
- end--]]
- end
- end
- else
- call()
- end
- -- cc.Device:vibrate(5)
- end
- log("2000000000-MJRoomView - addCallBack(runGameStartResponse)" )
- self:addCallBack(runGameStartResponse);
- end
-
- --是否有玩家洗牌
- function MJRoomView:isHavePlayerShuffle()
- local isFind = false
- if app.room.roomInfo.shuffleList then
- for k,v in ipairs(app.room.roomInfo.shuffleList) do
- if v.bShuffle == 1 then
- isFind = true
- break
- end
- end
- end
- return isFind
- end
-
- function MJRoomView:setLiangPaiVisible(bVisible)
- self.ui.Items.Layout_XiaoJu_LiangPai:setVisible(bVisible)
- end
-
-
- function MJRoomView:showXiaoJuView()
-
- self.direcionView:stopAllActions()
-
- self:setTingCardViewVisible(false)
-
- if self.xiaojuView then
- self.xiaojuView:removeFromParent()
- end
-
- local roomInfo = app.room.roomInfo
- -- for k,v in pairs(roomInfo.memberList) do
- -- local viewId = app.room:getViewIdByUserId(v.nUserId)
- -- if self.playerHandCards[viewId] then
- -- if viewId==MJDefine.MyViewId then
- -- --我自己则屏蔽触摸事件
- -- self.playerHandCards[viewId]:removeTouchEvent()
- -- else
- -- if v.result~=MJDefine.MJGameResultType.Win then --没有胡牌的玩家倒牌
- -- --显示所有底牌
- -- self.playerHandCards[viewId]:removeAllHandCards()
- -- self.playerHandCards[viewId]:createOpenHandCards(v.handCards)
- -- end
- -- end
- -- end
- -- end
-
- self.xiaojuView = MJRoomXiaoJuView:new(self.desktopType)
- self:addChild(self.xiaojuView)
-
-
- -- self:runAction(cc.Sequence:create(
- -- cc.DelayTime:create(2),
- -- cc.CallFunc:create(function()
-
- -- end)
- -- )
- -- )
- end
-
- --倒牌
- function MJRoomView:showOpenCard()
- local roomInfo = app.room.roomInfo
- for k,v in pairs(roomInfo.memberList) do
- local viewId = app.room:getViewIdByUserId(v.nUserId)
- if viewId and self.playerHandCards[viewId] then
- if viewId==MJDefine.MyViewId then
- -- 我自己则屏蔽触摸事件
- self.playerHandCards[viewId]:removeTouchEvent()
- else
- --倒牌
- self.playerHandCards[viewId]:removeAllHandCards()
- self.playerHandCards[viewId]:createOpenHandCards(v.handCards)
- end
- end
- end
- end
-
-
- -- 小局结算
- function MJRoomView:onGameXiaoJuResponse(data)
- local function runGameXiaoJuResponse(onEnd)
-
- local function callback()
- self:showXiaoJuView()
- if onEnd then
- onEnd()
- end
- end
-
- local roomInfo = app.room.roomInfo
- local resultInfo=json.decode(roomInfo.strResultInfo)
-
- self.direcionView:stopAllActions()
-
- --如果是解散直接return
- if roomInfo.stopFlag==MJDefine.StopFlag.STOP_FLAG_LONG_NOT_END or roomInfo.stopFlag==MJDefine.StopFlag.STOP_FLAG_DISBAND_GAME then
- if onEnd then
- onEnd()
- end
- return
- end
-
-
- --所有胡牌的人 考虑抢杠胡的问题
- local viewIds={}
- local failViewId=0
- for k,v in pairs(roomInfo.memberList) do
- local viewId = app.room:getViewIdByUserId(v.nUserId)
-
- if v.result==MJDefine.MJGameResultType.Win then
- table.insert(viewIds,viewId)
- --播放音效
- if viewId==MJDefine.MyViewId then
- MJSound.PlayWinGame()
- end
- elseif v.result==MJDefine.MJGameResultType.Fail then
- failViewId=viewId
- if viewId==MJDefine.MyViewId then
- MJSound.PlayLoseGame()
- end
- end
- end
-
- self:showOpenCard()
-
- --被抢杠的人回退补杠
- if resultInfo.hutype==MJDefine.MJHuType.QiangGangHu and roomInfo.stopFlag==MJDefine.StopFlag.STOP_FLAG_NORMAL then
- self.playerHandCards[failViewId]:retoreBuGang(resultInfo.hucard)
- end
-
- if #viewIds>0 then
- for k,viewId in pairs(viewIds) do
- local effect
- if k == #viewIds then --只有最后播放胡牌动画的回调一次就可以了
- effect=MJAnimationCompnent.CreateHuEffect(callback)
- --音效
- local userInfo=app.room:getUserInfoByViewId(viewId)
- if userInfo then
- if resultInfo.hutype==MJDefine.MJHuType.Zimo then
- MJSound.PlayOperateSound(userInfo.sex,MJDefine.MJOperateType.OPREATE_ZIMOHU)
- else
- MJSound.PlayOperateSound(userInfo.sex,MJDefine.MJOperateType.OPREATE_DIANPAOHU)
- end
- end
- else
- effect=MJAnimationCompnent.CreateHuEffect()
- end
- if effect then
- self.ui.Items.Layout_Player:addChild(effect)
- effect:setLocalZOrder(1000)
- effect:setPosition(self.playerHandCards[viewId]:getAnimationPostion())
- end
- end
- else
- if roomInfo.stopFlag==MJDefine.StopFlag.STOP_FLAG_HUANG_ZHUANG then
- local effect=MJAnimationCompnent.CreateLiuJuEffect(callback)
- self.ui.Items.Layout_Player:addChild(effect)
- effect:setLocalZOrder(1000)
- MJSound.PlayHuangZhuang()
- else
- callback()
- end
- end
-
- end
- log("2000000000-MJRoomView - addCallBack(runGameXiaoJuResponse)" )
- self:addCallBack(runGameXiaoJuResponse);
- end
-
- -- 大局结算
- function MJRoomView:onGameDaJuResponse(data)
- local function runGameDaJuResponse(onEnd)
- local roomInfo=app.room.roomInfo
- --如果是解散直接跳转总结算
- if roomInfo.stopFlag==MJDefine.StopFlag.STOP_FLAG_LONG_NOT_END or roomInfo.stopFlag==MJDefine.StopFlag.STOP_FLAG_DISBAND_GAME then
- self.direcionView:stopAllActions()
- self:resetGame()
- local view=MJRoomDaJuView:new()
- view:setAnchorPoint(cc.p(0.5, 0.5))
- app:showWaitDialog(view)
- self:showGameOverAward()
- end
- app.room:dispatchEvent({name = GAME_EVENT.DISSMISS_CLOSE});
- if onEnd then
- onEnd()
- end
- end
- log("2000000000-MJRoomView - addCallBack(runGameDaJuResponse)")
- self:addCallBack(runGameDaJuResponse);
- end
-
- function MJRoomView:onUserReadyResponse(response)
- -- self:setPlayerVisible(false)
- local uids = {}
- for k,v in pairs(app.room.roomInfo.memberList) do
-
- local nSeatShowId = app.room:getViewIdByUserId(v.nUserId)
- self.playerView:setReadyStatus(nSeatShowId,v.nPlayerFlag == 1)
- self.playerView:updatePlayerInfo(nSeatShowId)
-
- uids[v.nUserId] = true
- end
-
- if self.messageView then
- self.messageView:setPlayerUids(uids)
- end
-
- local nUserId = app.room:getMyUserId()--app.user.loginInfo.uid
- if response and response.nUserId==nUserId then
- self.toolView:updateButton(true)
- self:resetGame()
- else
- self.toolView:updateButton()
- end
-
- if response and response.nUserId==nUserId then
- self:resetGame()
- end
- end
-
-
- -- 玩家收到解散房间的请求
- function MJRoomView:onDismissResponse(event)
- if not event or not event.response then
- return
- end
-
- logE("onDismissResponse() response = ", event.response)
-
- local response = event.response
-
- --当前时间
- app.room.roomInfo.nDismissStateTime = response.timeLeft
- --总的时间
- app.room.roomInfo.nDismissToTalTime = app.room.roomInfo.nDisbandTimeout
- --显示解散(此标志会影响闹钟时间会冻住)
- app.room.roomInfo.nShowDismiss = true
-
- if response.operateType == 1 then
- local initiateUserId = response.nUserId
- if response.memberList ~= nil then
- for k,v in pairs(response.memberList) do
- if v.dismissState == 1 then
- initiateUserId = v.nUserId
- end
- end
- end
- --如果上次的解散界面还存在 先发送关闭事件
- app.room:dispatchEvent({name = GAME_EVENT.DISSMISS_CLOSE})
-
- local view = require("luaScript.Views.Room.RoomDismissView"):new(initiateUserId,app.room.roomInfo.memberList,response.timeLeft)
- view:setAnchorPoint(cc.p(0.5, 0.5))
- app:showWaitDialog(view)
- -- self.ui:sendMsg(app.room, MJDefine.MJEvent.CallReadyRequest)
- -- if response.memberList ~= nil then --自己发起
- -- for k,v in pairs(response.memberList) do
- -- if v.dismissState == 1 then
- -- local view = MJRoomDismissView:new(v.nUserId);
- -- view:setAnchorPoint(cc.p(0.5, 0.5));
- -- app:showWaitDialog(view);
- -- return
- -- end
- -- end
- -- else --其他收到
- -- local view = MJRoomDismissView:new(response.nUserId);
- -- view:setAnchorPoint(cc.p(0.5, 0.5));
- -- app:showWaitDialog(view);
- -- end
- else --如果不是发起操作则只转发状态给解散界面
- local memberStatus={}
- -- local userId = response.nUserId
- if response.memberList ~= nil then
- for k,v in pairs(response.memberList) do
- table.insert(memberStatus,{userId = v.nUserId, status = v.dismissState})
- -- if v.dismissState == 1 then
- -- initiateUserId = v.nUserId
- -- end
- end
- else
- table.insert(memberStatus,{userId = response.nUserId, status = response.operateType})
- end
- app.room:dispatchEvent({name = GAME_EVENT.DISSMISS_UPDATE_STATUS , memberStatus = memberStatus});
- end
- end
-
- --更新庄家
- function MJRoomView:updateBanker()
- --隐藏所有的庄家标志
- -- self:setBankerVisible()
- --只显示当前的庄家座位号
- local nBankerSeatId = app.room.roomInfo.nBankSeatId
- local viewId = app.room:getViewIdBySeatId(nBankerSeatId)
- self.playerView:setBankerVisible(viewId,true)
- -- if self.allNodes[viewId] then
- -- self.allNodes[viewId].banker:setVisible(true)
- -- else
- -- showTooltip("庄家椅子号"..nBankerSeatId.."不匹配")
- -- end
- end
-
- -- 更新玩家基本信息 : 昵称、头像
- -- index :是玩家展示出来的座位号
- function MJRoomView:updatePlayerInfo(index)
-
- logE("MJRoomView:updatePlayerInfo() index = ", index)
-
- local nodes = self.allNodes[index]
-
- local nUserId = app.room.seatShowList[index]
-
- local roomInfo = app.room.roomInfo
-
- local memberInfo = app.room.roomInfo.memberList[nUserId]
- if memberInfo then
-
- --[[if memberInfo.nPlayerFlag == LHQ_GAME_CONST.LHQ_GAME_CONST_ONLOOKER then
- return
- end--]]
-
- nodes.player:setVisible(true)
-
- local userInfo = json.decode(memberInfo.userInfo)
-
- if not userInfo then
- return
- end
-
- -- 玩家名字
- local nickname = userInfo.nickname
- nickname = getSubStringNickname(nickname)
- nodes.name:setText(tostring(nickname))
-
- nodes.score:setText(tostring(memberInfo.nTotalMoney))
- -- 玩家头像
- local nodeHead = nodes.head;
-
- --先设置默认头像
- local width = nodeHead:getContentSize().width
-
- setPlayerHeadImage(nUserId, userInfo.headimgurl, nodeHead)
- else
- nodes.player:setVisible(false)
- end
- end
-
-
-
- function MJRoomView:onOtherDroppedResponse(data)
- if not data.response.nUserId then
- return
- end
- local nUserId = data.response.nUserId
- local nOnlineStatus = data.response.nOnlineStatus
- local viewId = app.room:getViewIdByUserId(nUserId)
- self.playerView:setPlayerOffLineVisible(nOnlineStatus == MJDefine.PlayOnlineStatus.offline,viewId)
- end
-
- function MJRoomView:onUserExitResponseRoom(data)
- local function runUserExitResponseRoom(onEnd)
- log("2000000000-MJRoomView - runUserExitResponseRoom()" )
- local response = data.response
- -- 0: 不退出, 1: 退出
- if response.logoutFlag == 1 then
- --房间号
- local roomid = app.room.roomInfo.nShowTableId
- --app:gotoView(import("luaScript.Views.Main.MainView"):new(app.gameId,roomid));
- gotoMainView(app.gameId,roomid)
- end
- app.room:dispatchEvent({name = "onUserExitResponseHall"});
- logE("88888-onUserExitResponseRoom onEnd")
- if onEnd then
- onEnd()
- end
- end
- log("2000000000-MJRoomView - addCallBack(runUserExitResponseRoom)" )
- self:addCallBack(runUserExitResponseRoom);
- end
-
-
-
- -- 服务器广播玩家数据发生变化
- function MJRoomView:onGpsChangeResponse(data)
- logD("MJRoomView:onGpsChangeResponse()")
- if not data or not data.nUserId then
- return
- end
-
- local roomInfo = app.room.roomInfo
-
- local nUserId = data.nUserId
- logD("MJRoomView:onGpsChangeResponse()", tostring(nUserId))
-
- self:checkGpsDistance(nUserId,roomInfo.nGameStartCount==0)
- end
-
- function MJRoomView:initGpsComponent()
- if cc.Application:getInstance():getTargetPlatform() == 0 then
- self.ui.Items.Button_GPS:setVisible(false)
- return
- end
-
- local versionCode = getAppVersionCode()
- versionCode = tonumber(versionCode) or 0
-
- logD("MJRoomView:initGpsComponent() versionCode = ", versionCode)
- logD("MJRoomView:initGpsComponent() isReviewVersion = ", isReviewVersion()==true and 1 or 0)
-
-
- self.singleComponent = import("luaScript.Views.Room.RoomSinglePowerComponent"):new(self.ui.Items.ImageView_Single,self.ui.Items.LoadingBar_Power)
-
- if isReviewVersion() then -- or versionCode < 110
- self.ui.Items.Button_GPS:setVisible(false)
- return
- end
-
- -- 创建 gps 组件
- -- self.gpsComponent = import("luaScript.Views.Room.RoomGpsComponent"):new(self.ui.Items.Button_GPS)
-
- local function exitRoomCallback()
- local isGameStart = app.room.roomInfo.nGameStartCount > 0
- if isGameStart then
- app.room:requestDismissRoom(1)
- else
- self.ui:sendMsg(app.room, MJDefine.MJEvent.CallLeaveRequest)
- end
- end
-
- self.gpsComponent = import("luaScript.Views.Room.RoomGpsComponentView"):new(4,self.ui.Items.Button_GPS,exitRoomCallback,exitRoomCallback)
- self:addChild(self.gpsComponent)
-
- -- GPS 按钮
- self.ui.Items.Button_GPS:registerClick(handler(self, self.showGpsView))
-
- -- 我的GPS数据发生变化时检测是否需要通知服务器
- -- self:bindEvent(app, "onGpsInoChanged", handler(self, self.checkMyGpsNeedUpdate))
-
- -- self.isInitCheckGps = false
-
- -- 进入时检测一遍我的GPS数据是否需要更新
- -- self:checkMyGpsNeedUpdate()
- end
-
- -- 检查服务器记录的我的GPS数据是最新的,如果不是,则请求更新
- -- function MJRoomView:checkMyGpsNeedUpdate(event)
- -- logD("MJRoomView:checkMyGpsNeedUpdate()")
-
- -- if self.isInitCheckGps and not event then
- -- return
- -- end
-
- -- self.isInitCheckGps = true
-
- -- local nMyUserId = app.room:getMyUserId()--app.user.loginInfo.uid
- -- local myMemberInfo = app.room.roomInfo.memberList[nMyUserId]
- -- if myMemberInfo then
- -- local userInfo = json.decode(myMemberInfo.userInfo)
- -- if userInfo then
- -- local gpsInfo = userInfo.gpsInfo
- -- local isNewest = app.user:isGpsInfoNewest(gpsInfo)
- -- logD("MJRoomView:checkMyGpsNeedUpdate() gpsInfo is isNewest = ", tostring(isNewest))
- -- if not isNewest then
- -- app.room:onGpsChangeRequest();
- -- else
- -- logD("MJRoomView:checkMyGpsNeedUpdate() gpsInfo is newest")
- -- end
- -- else
- -- logD("MJRoomView:checkMyGpsNeedUpdate() userInfo is nil")
- -- end
- -- else
- -- logD("MJRoomView:checkMyGpsNeedUpdate() myMemberInfo is nil")
- -- end
- -- end
-
- -- 更新所有玩家的信息到GPS组件
- function MJRoomView:updateAllGpsInfo()
- local userInfoList = {}
- for nUserId, memberInfo in pairs(app.room.roomInfo.memberList) do
- local nSeatId = memberInfo.nSeatId
- local userInfo = memberInfo.userInfo
- userInfoList[nUserId] = {nSeatId = nSeatId, userInfo = userInfo}
- end
- if self.gpsComponent then
- self.gpsComponent:updateUserInfos(userInfoList)
- end
- end
-
- -- 检测玩家与其他玩家之间的距离
- -- 如果不传参数,则检测所有玩家相互之间的距离
- -- function MJRoomView:checkGpsDistance(curUserId,isOpenGpsView)
- -- --if app.room.roomInfo.nGameStartCount > 0 then
- -- -- return
- -- --end
- -- self:updateAllGpsInfo()
- -- if self.gpsComponent then
- -- local isDanger = self.gpsComponent:checkGpsDistance(curUserId)
- -- if isDanger and isOpenGpsView then
- -- self:showGpsView()
- -- showTooltip("玩家距离过近或者未开启GPS!")
- -- end
- -- end
- -- end
-
- -- 显示GPS界面
- function MJRoomView:showGpsView()
- logD("MJRoomView:showGpsView()")
- playBtnEffect()
- local isGameStart = app.room.roomInfo.nGameStartCount > 0
- -- self:updateAllGpsInfo()
- if self.gpsComponent then
- self.gpsComponent:showGpsView(isGameStart)
- end
- end
-
- function MJRoomView:onTingCardStatus()
- local myUserId=app.user.loginInfo.uid
- local memberList=app.room.roomInfo.memberList
- print("---------onTingCardStatus-----------")
- dump(myUserId)
- dump(memberList[myUserId])
- if memberList[myUserId] then
- local nTingStatus=memberList[myUserId].nTingStatus
- if nTingStatus == MJDefine.MJTingStatus.Ting then
- print("---------onTingCardStatus-----------1")
- self:setChaTingCardViewVisible(true)
- else
- print("---------onTingCardStatus-----------0")
- self:setChaTingCardViewVisible(false)
- end
- end
- end
-
- function MJRoomView:onTingCardResult(data)
- if data.response.tingType==MJDefine.MJTingType.QuanTing then
- self:setChaTingCardViewVisible(true,{})
- else
- self:setChaTingCardViewVisible(true,data.response.tingCards)
- end
- end
-
- function MJRoomView:showTing(evet)
- local roomInfo=app.room.roomInfo
- if evet.card and roomInfo.tings and roomInfo.tings[evet.card] then
- self:setTingCardViewVisible(true,roomInfo.tings[evet.card])
- else
- self:setTingCardViewVisible(false)
- end
- end
-
- function MJRoomView:pushTing()
-
- local function runPushTing(onEnd)
- log("2000000000-MJRoomView - runPushTing()" )
- if self.playerHandCards[MJDefine.MyViewId] then
- self.playerHandCards[MJDefine.MyViewId]:pushTing()
- end
- if onEnd then
- onEnd()
- end
- end
- log("2000000000-MJRoomView - addCallBack(runPushTing)" )
- self:addCallBack(runPushTing);
- end
-
- function MJRoomView:onBroadcastFaststart(data)
- local response = data.response
- local remove = false
- if response.nUserId and response.nStatus then
- if response.nStatus == 3 or response.nStatus>4 then
- remove = true
- end
- end
- if not remove then
- for _,v in ipairs(response.pList) do
- if v.nStatus == 3 or v.nStatus>4 then
- remove = true
- end
- end
- end
- if response.timeOut <=0 then remove = true end
-
- if self._fastRequestView == nil then
- if remove then return "" end
- local requesterId = 0
- for _,v in ipairs(response.pList) do
- if v.nStatus == 1 then
- requesterId = v.nUserId
- end
- end
- if requesterId<=0 then return "" end
- local view = import("mj.luaScript.Views.Room.MJRequestStartView"):new(requesterId)
- view:setAnchorPoint(cc.p(0.5, 0.5))
- view:showItems(response)
- app:showWaitDialog(view)
- self._fastRequestView = view
- else
- if remove then
- local userInfo = app.room.roomInfo.memberList[response.nUserId]
- self._fastRequestView:removeSelf()
- self._fastRequestView = nil
- if userInfo then
- local u = json.decode(userInfo.userInfo)
- local txt = string.format("玩家【%s】拒绝立即开局", u.nickname)
- showTooltip(txt)
- end
- app.room:resetFastInfo()
- --self.toolView:showFastStart(true)
- else
- self._fastRequestView:updateView(response)
- end
- end
- end
-
- function MJRoomView:onFastStartSucc(data)
- if self._fastRequestView then
- self._fastRequestView:removeSelf()
- self._fastRequestView = nil
- end
- --self.toolView:showFastStart(false)
- self.playerView:setPlayerVisible(false)
- self:updateRoomBaseData()
- end
-
- function MJRoomView:onWaitOperate(data)
- --等待操作的UID
- local nUserId = data.response.nUserId
- --操作类型
- local opType = data.response.opType
-
- local viewId = app.room:getViewIdByUserId(nUserId)
-
- local waitSprite = nil
- if opType==MJDefine.MJOperateType.OPREATE_PENG then
- waitSprite = cc.Sprite:create("mj/res/ui/zy_fangjian/operate/mj_effect_wait_peng.png")
- elseif opType==MJDefine.MJOperateType.OPREATE_ZHIGANG or opType==MJDefine.MJOperateType.OPREATE_BAGANG or opType==MJDefine.MJOperateType.OPREATE_ANGANG then
- waitSprite = cc.Sprite:create("mj/res/ui/zy_fangjian/operate/mj_effect_wait_gang.png")
- elseif opType==MJDefine.MJOperateType.OPREATE_DIANPAOHU or opType==MJDefine.MJOperateType.OPREATE_QIANG_GANG_HU then
- waitSprite = cc.Sprite:create("mj/res/ui/zy_fangjian/operate/mj_effect_wait_hu.png")
- end
-
- if waitSprite then
- self.ui.Items.Layout_Player:addChild(waitSprite)
- waitSprite:setLocalZOrder(1000)
- waitSprite:setPosition(self.playerHandCards[viewId]:getAnimationPostion())
- table.insert(self.waitOperates,waitSprite)
- end
- end
-
- function MJRoomView:bindAllEvent()
- --[[
- 消息分类管理
- ]]
-
- --用户状态(包括准备,其他玩家进入或者离开通知,离线等)
- self:bindUserStatedMessage()
-
- --私人场消息(包括解散等)
- self:bindPrivateMessage()
-
- --游戏消息
- self:bindGameMessage()
-
- --游戏场景消息
- self:bindGameSceneMessage()
-
- --更换视图
- -- self:bindEvent(app , MJDefine.MJEvent.ChangeViewType , handler(self , self.onChangeViewType));
-
- self:bindEvent(app , MJDefine.MJEvent.ChangeViewBG , handler(self , self.onChangeViewBG));
-
- -- self:bindEvent(app , MJDefine.MJEvent.ChangeChatEnable , handler(self , self.onChangeChatEnable));
-
- --绑定更换桌布事件
- -- self:bindEvent(app , "onChangeTable" , handler(self , self.onChangeTable));
- --发送道具
- -- self:bindEvent(app.room,"showProp" , handler(self , self.showProp));
-
- self:bindExtendMessage()
- end
-
- function MJRoomView:onChangeViewType(event)
- if self.desktopType ~= event.desktopType then
- self.desktopType = event.desktopType
- end
- end
-
- function MJRoomView:onChangeViewBG(event)
- self:changeGameBg()
- end
-
- function MJRoomView:onChangeChatEnable()
- if not self.messageView or tolua.isnull(self.messageView) then
- return
- end
- local voiceEnable = tonumber(loadUserInfo("voiceEnable")) or 1
- local propEnable = tonumber(loadUserInfo("propEnable")) or 1
- self.messageView:setVoiceEnabled(voiceEnable==1)
- self.messageView:setPropEnabled(propEnable==1)
- end
-
- --绑定扩展消息
- function MJRoomView:bindExtendMessage()
-
- end
-
-
- --用户状态消息
- function MJRoomView:bindUserStatedMessage()
- --默认状态
- self:bindEvent(app.room , "defaultState" , handler(self , self.defaultState));
- -- 玩家准备
- self:bindEvent(app.room , MJDefine.MJEvent.UserReadyResponse , handler(self , self.onUserReadyResponse));
- -- 其他玩家进入房间
- self:bindEvent(app.room , MJDefine.MJEvent.OtherSitDownResponse , handler(self , self.onOtherSitDownResponse));
- -- 其他玩家退出房間
- self:bindEvent(app.room , MJDefine.MJEvent.OtherLogoutResponse , handler(self , self.onOtherLogoutResponse));
- -- 其他玩家掉线
- self:bindEvent(app.room , MJDefine.MJEvent.OtherDroppedResponse , handler(self , self.onOtherDroppedResponse));
- -- 用户T出
- self:bindEvent(app.room , MJDefine.MJEvent.UserExitResponseRoom , handler(self , self.onUserExitResponseRoom));
-
- -- 玩家的GPS信息发生变化
- self:bindEvent(app.room , MJDefine.MJEvent.GpsChangeResponse , handler(self , self.onGpsChangeResponse));
-
- end
-
- --私人场消息
- function MJRoomView:bindPrivateMessage()
- -- 玩家收到解散房间的请求
- self:bindEvent(app.room , MJDefine.MJEvent.DismissResponse , handler(self , self.onDismissResponse));
- end
-
- --游戏消息
- function MJRoomView:bindGameMessage()
- -- 游戏开始
- self:bindEvent(app.room , MJDefine.MJEvent.GameStartResponse , handler(self , self.onGameStartResponse));
- -- 开始给桌子上用户发牌
- self:bindEvent(app.room , MJDefine.MJEvent.GameSendCardResponse , handler(self , self.onGameSendCardResponse));
- -- 系统发给自己可串可哨的消息
- -- self:bindEvent(app.room , "onSystemOperationStart" , handler(self , self.onSystemOperationStart));
- -- 广播桌子上所有玩家庄家起手操作
- self:bindEvent(app.room , MJDefine.MJEvent.BankerOutCard, handler(self , self.onBankerOutCard));
- -- 出牌错误
- self:bindEvent(app.room , MJDefine.MJEvent.OutCardError , handler(self , self.onOutCardError));
- -- 出牌成功
- self:bindEvent(app.room , MJDefine.MJEvent.OutCardSuccess, handler(self , self.onOutCardSuccess));
-
- self:bindEvent(app.room , MJDefine.MJEvent.TurnOutCard , handler(self , self.onTurnOutCard));
-
- -- 抢杠胡
- self:bindEvent(app.room , MJDefine.MJEvent.QiangGangHu, handler(self , self.onQiangGangHu));
- -- 弃牌
- self:bindEvent(app.room , MJDefine.MJEvent.OutCardResponse , handler(self , self.onOutCard));
- -- 操作错误
- self:bindEvent(app.room , MJDefine.MJEvent.OperationError, handler(self , self.onOperationError));
- -- 先操作玩家
- -- self:bindEvent(app.room , "onOperationFirst", handler(self , self.onOperationFirst));
- -- 操作成功
- self:bindEvent(app.room , MJDefine.MJEvent.OperationCodeSuccess , handler(self , self.onOperationCodeSuccess));
- -- 听牌
- self:bindEvent(app.room , MJDefine.MJEvent.TingSatus, handler(self , self.onTingCardStatus));
- self:bindEvent(app.room , MJDefine.MJEvent.TingResult, handler(self , self.onTingCardResult));
- self:bindEvent(app.room , MJDefine.MJEvent.ShowTing, handler(self , self.showTing));
- self:bindEvent(app.room , MJDefine.MJEvent.PushTing, handler(self , self.pushTing));
-
-
- self:bindEvent(app.room , MJDefine.MJEvent.WaitOperate, handler(self , self.onWaitOperate))
- -- 听牌
- -- self:bindEvent(app.room , "onDaiXing",handler(self , self.onDaiXing));
- --弃胡通知自己
- -- self:bindEvent(app.room , "onQiHuSelfResponese",handler(self , self.onQiHuSelfResponese));
- --弃胡通知其他
- -- self:bindEvent(app.room , "onOtherQiHuTongZhi",handler(self , self.onOtherQiHuTongZhi));
-
- self:bindEvent(app.room , MJDefine.MJEvent.BraodcastFastStart , handler(self , self.onBroadcastFaststart));
- self:bindEvent(app.room , MJDefine.MJEvent.FastStartSucc , handler(self , self.onFastStartSucc));
-
- self:bindEvent(app.room , MJDefine.MJEvent.GameXiaoJuResponse , handler(self , self.onGameXiaoJuResponse));
- self:bindEvent(app.room , MJDefine.MJEvent.GameDaJuResponse , handler(self , self.onGameDaJuResponse));
- -- user pass
- self:bindEvent(app.room , MJDefine.MJEvent.USER_PASS, handler(self, self.onUserPassRequest))
- end
-
- --场景恢复
- function MJRoomView:bindGameSceneMessage()
- local function onEnterRoomSuccess(event)
- if tolua.isnull(self.ui) then
- logE("self.is null")
- return
- end
- local roomInfo = app.room.roomInfo
- local myUserId = app.room:getMyUserId()
- for userId,v in pairs(roomInfo.memberList) do
- local viewId = app.room:getViewIdByUserId(userId)
- --出牌瞬间重连,会先收到重连消息再收到出牌成功,导致多一张牌,这时要在出牌成功那里删一次牌
- if self.playerHandCards[viewId] and v.handCards and type(v.handCards) == 'table' then
- if userId == myUserId then
- local rHandCards = #v.handCards
- local curHandCards = self.playerHandCards[viewId]:getHandCardsNum()
- if curHandCards+1 == rhandCards then
- self.needDeleteOutCard = true
- end
- end
- end
- end
- self:stopAllActions()
- self:defaultState()
- self:onGameReconnection()
- self:startGame()
- end
- app.hall:addEventListener("onEnterRoomSuccess", onEnterRoomSuccess)
- end
-
- --按钮位置调整
- function MJRoomView:updateButtonPosition()
- if not self.ui.Items.Layout_Button then return end
- --if not self.ui.Items.Button_Invite_Club then return end
- self.ui.Items.Button_Ready:getParent():setVisible(self.ui.Items.Button_Ready:isVisible())
- --self.ui.Items.Button_Invite:getParent():setVisible(self.ui.Items.Button_Invite:isVisible())
- if self.ui.Items.Button_Invite_Club then
- self.ui.Items.Button_Invite_Club:getParent():setVisible(self.ui.Items.Button_Invite_Club:isVisible())
- end
- if self.ui.Items.Layout_Button then
- self.ui.Items.Layout_Button:requestDoLayout()
- self.ui.Items.Layout_Button:doLayout()
- end
- end
-
- --
- function MJRoomView:onClickInviteClub()
- playBtnEffect()
-
- if app.club_php.clubID and app.club_php.clubID ~= 0 then
- local roomInfo = app.room.roomInfo;
- if roomInfo and roomInfo.nShowTableId then
- local strInvite = MJFunction.getClubInviteWanFa(roomInfo.gameId or app.gameId, roomInfo)
- local view = import("luaScript.Views.Club.ClubInvite"):new(roomInfo.nShowTableId, strInvite)
- view:setAnchorPoint(cc.p(0.5, 0.5))
- app:showWaitDialog(view)
- end
- end
- end
-
- --托管状态,服务器下发过操作,客户端隐藏操作界面
- function MJRoomView:onUserPassRequest( data )
- local response = data.response
- if app.room:getMyUserId() == response.nUserId then
- self.playerHandCards[MJDefine.MyViewId]:hideOperate()
- end
- end
-
- -- =========================================== 合并框架新方法 ==============================================
-
- ---
- -- 根据规则弹出规则,目前每次登陆
- -- @return boolean
- --
- function MJRoomView:getIsNeedShowRule()
- local key = "AutoShowRule_"..app.gameId
- if not app[key] then
- app[key] = true
- return true
- else
- return false
- end
- end
-
- ---
- -- 清除lua缓存
- -- @return
- --
- function MJRoomView:cleanCache()
- local clearList = {'mj.luaScript', 'mj_hsb.luaScript'};
- local subGameConfig=getSubGameConfig(app.gameId) or {}
- table.insert(clearList, subGameConfig.rootName)
-
- while (subGameConfig and subGameConfig.fremworkId and subGameConfig.fremworkId > 0) do
- subGameConfig = getSubGameConfig(subGameConfig.fremworkId)
- if not subGameConfig or not subGameConfig.rootName then
- break
- end
- table.insert(clearList, subGameConfig.rootName)
- end
-
- local preload = package.loaded
- for luaPath, _ in pairs(package.loaded or {}) do
- for __, str in ipairs(clearList or {}) do
- local res = string.find( luaPath, str) or 0
- if res > 0 then
- package.loaded[luaPath] = nil
- end
- end
- end
- end
-
- -- 分辨率改变回调(针对部分机型切后台后,导致牌数据位置不对(宽高分辨率对调了))
- function MJRoomView:applicationScreenSizeChanged()
- print('MJRoomView:applicationScreenSizeChanged')
-
- if not self then
- print('MJRoomView:applicationScreenSizeChanged return not self')
- return
- end
-
- if tolua.isnull(self) then
- print('MJRoomView:applicationScreenSizeChanged return tolua.isnull(self)')
- return
- end
-
- -- 出现小局不请求重连
- -- if self.xiaojuView and self.xiaojuView:isVisible() then
- -- print('MJRoomView:applicationScreenSizeChanged return self.xiaojuView is showing')
- -- return
- -- end
-
- local callFunc = function(onEnd)
- if self.playerHandCards[MJDefine.MyViewId].isUseNew3D then
- if self.playerHandCards[MJDefine.MyViewId]:isUseNew3D() then
- MJDefine.loadMJConfig(self.desktopType)
- end
- end
- self:requestReconnect()
-
- if onEnd then
- onEnd()
- end
- end
-
- local winSize = cc.Director:getInstance():getWinSize()
- for i, v in pairs(self.playerHandCards) do
- if v:getHandCardPosInitY() > winSize.height then
- self:addCallBack(callFunc)
- break
- end
- end
-
- end
-
- -- 请求重连
- function MJRoomView:requestReconnect()
- if not MJDefine then
- return
- end
-
- if not MJDefine.MJEvent then
- return
- end
-
- if not MJDefine.MJEvent.GetTableInfo then
- return
- end
-
- self.ui:sendMsg(app.room,MJDefine.MJEvent.GetTableInfo)
- end
- ---
- -- 显示抽奖界面
- --
- function MJRoomView:showGameOverAward()
- if not (dd and dd.IGameOverAward) then
- return
- end
- self:runDelay(0.1, function ( )
- -- 延迟0.1秒执行,可能有些游戏弹大结算的时候还未收到抽奖消息
- dd.IGameOverAward.showAwardView();
- end)
- end
- ---
- -- 检测是否可以解散房间
- -- @param
- -- @return
- --
- function MJRoomView:checkCanDismiss( )
- local onCanDismissCallback = function (info)
- local nUserId = app.room:getMyUserId()
- local roomInfo = app.room.roomInfo or {}
- local canDismiss = (tonumber(info.canDismiss or 1) == 1) or roomInfo.nRoomOwnedUid == nUserId or dd.IClub.isAdmin()
- if roomInfo.nGameStartCount == 0 and roomInfo.nRoomOwnedUid ~= nUserId then
- canDismiss = false
- end
- self:onCanDismissCallback(canDismiss)
- end
-
- if dd.IClub.getCanDismiss then
- local canDismiss = dd.IClub.getCanDismiss(onCanDismissCallback)
- if canDismiss then
- onCanDismissCallback({canDismiss = canDismiss})
- end
- end
- end
-
- function MJRoomView:onCanDismissCallback(canDismiss)
- if not self.toolView then
- return
- end
- if self.toolView.ui.Items.Button_Dismiss then
- self.toolView.ui.Items.Button_Dismiss:setEnabled(canDismiss)
- end
- end
-
- return MJRoomView
|