local Functions = require("pk_zgwrddz.luaScript.zgwrDdzFunctions") local DdzGameOverView = class("DdzGameOverView", cc.UIView) local GameOverItem = require("pk_zgwrddz.luaScript.Views.Room.Node.zgwrDdzGameOverItem") function DdzGameOverView:ctor( overData ) self._data = overData local ui = loadUI("pk_zgwrddz/res/ui/ui_room/ui_wrddz_daju.ui") self.ui = ui self:addChild(ui) self:initUi() self:setPlayerInfo() -- 初始化再来一轮 self:initPlayGameAgain() end function DdzGameOverView:initUi() local roomInfo = app.room:getRoomInfo() self.ui.Items.Button_Share:registerClick(handler(self , self.onBtnShareClicked)) self.ui.Items.Button_Over:registerClick(handler(self , self.onBtnGameOverClicked)) self.ui.Items.Button_PreventShare:registerClick(handler(self , self.onBtnPreventShareClicked)) local newRule = "" .."五人斗地主" newRule = newRule.." 房间号:"..tostring(self._data.nShowTableId) local curCount = roomInfo.nGameStartCount or 0 local str = string.format("%02d/%02d局", curCount, roomInfo.nTotalGameNum) newRule = newRule.." "..str self.ui.Items.txtRoomRule:setString(newRule)--(string.format("%s", self._data.roomRule or "")) if app.club_php.clubID and app.club_php.clubID ~= 0 then self.ui.Items.txtRoundNum:setText("茶馆ID:"..app.club_php.clubID) else self.ui.Items.txtRoundNum:setText("") end self.ui.Items.txtRoomID:setText(os.date("%Y-%m-%d %X",self._data.endTime)) local gameConfig = getSubGameConfig(app.gameId) or {}; if gameConfig.gameDataConfig and gameConfig.gameDataConfig.isClosePlayAgain == true then self.ui.Items.Layout_Button_PlayAgain:setVisible(false) end if not app.config.ModuleConfig.IsSupportZhanJiUrl then self.ui.Items.Layout_PreventShare:setVisible(false); end if isReviewVersion() then self.ui.Items.Layout_Share:setVisible(false) self.ui.Items.Layout_PreventShare:setVisible(false) end self.ui.Items.Layout_Buttons:requestDoLayout() self.ui.Items.Layout_Buttons:doLayout() end function DdzGameOverView:setPlayerInfo() local maxUserId = self._data.players[1].userId local maxScore = tonumber(self._data.players[1].totalScore) for i,v in ipairs(self._data.players) do v.totalScore = tonumber(v.totalScore) if v.totalScore > maxScore then maxUserId = v.userId maxScore = v.totalScore end end local roomInfo = app.room:getRoomInfo() for i,v in ipairs(self._data.players) do v.isBigWin = v.totalScore == maxScore--v.userId == maxUserId v.isHost = v.userId == roomInfo.nRoomOwnedUid local item = self:createItem(v) self.ui.Items.Layout_items:addChild(item) end end function DdzGameOverView:onBtnShareClicked( sender ) playBtnEffect() local fileName = cc.FileUtils:getInstance():getWritablePath()..tostring(self._data.nShowTableId).."_screen.jpg" cc.FileUtils:getInstance():screenToFile(fileName, function(ret) if 1 == tonumber(ret) then local info = {} info.scene = "talk" info.contentType = "image" info.image = fileName info.isShareZhanjiUrl = true info.imageWidth = 800 info.thumbWidth = 100 --app.plugin:shareGame(info) info.copyData={ type=1, tableId=self._data.nShowTableId, userInfos={}, gameId=GAME_IDS.zgWuRenDouDiZhu, } for nUserId,totalData in pairsByKeys(self._data.players) do local userInfo = app.room:getUserInfo(totalData.userId) --昵称 local nickname = getShortName2(totalData.nickname) or "" local totalScore = totalData.totalScore table.insert(info.copyData.userInfos,{nickname=nickname,totalScore=totalScore}) end local view = import("luaScript.Views.Main.ShareView"):new(info,nil,{endtime=self._data.endTime}) view:setAnchorPoint(cc.p(0.5, 0.5)) app:showWaitDialog(view) else showTooltip("截图保存失败") end end ) end function DdzGameOverView:onBtnGameOverClicked( sender ) playBtnEffect() app:gotoView(import("luaScript.Views.Main.MainView"):new(GAME_IDS.zgWuRenDouDiZhu)) end function DdzGameOverView:onBtnPreventShareClicked() app.waitDialogManager:showWaitNetworkDialog("获取分享链接") local onGetUrlCallback = function(url) app.waitDialogManager:closeWaitNetworkDialog() if url then local imagePath = cc.FileUtils:getInstance():getWritablePath().."icon.png" local gameName = getSubGameName(GAME_IDS.zgWuRenDouDiZhu) or "川南棋牌" local info = {} -- info.contentType = "image" info.image = fileName info.title = gameName.."战绩" -- info.imageWidth = 800 info.menuIdxs = {1, 4, 5, 6} info.FFQFlag = true -- info.isShareZhanjiUrl = false info.copyData={ type=1, tableId=self._data.nShowTableId, userInfos={}, gameId=GAME_IDS.zgWuRenDouDiZhu, } local content = nil; local memberList = app.room.roomInfo.memberList--self._overData.nTotalPlayerInfos for k,v in pairs(self._data.players) do local userInfo = app.room:getUserInfo(v.userId) --昵称 local nickname = v.nickname or "" local totalScore = tonumber(v.totalScore) table.insert(info.copyData.userInfos,{nickname=getShortName2(nickname),totalScore=totalScore}) local strUserInfo = "" if totalScore > 0 then strUserInfo = string.format("%s(+%s)", getShortName2(nickname), totalScore) else strUserInfo = string.format("%s(%s)", getShortName2(nickname), totalScore) end if content then content = content .. "," .. strUserInfo else content = strUserInfo end end local sharUrl = string.format("%s?uid=%s&gameid=%s&app=%s&roomid=%s&endtime=%s", url, app.user.loginInfo.uid, GAME_IDS.zgWuRenDouDiZhu, getAppId(), self._data.nShowTableId, self._data.endTime or os.time()) info.url = sharUrl info.description = content dump(info) local view = import("luaScript.Views.Main.ShareView"):new(info) view:setAnchorPoint(cc.p(0.5, 0.5)) app:showWaitDialog(view) else showTooltip("获取分享用的链接失败") end end app.php:initShareZhanJiToUrl(onGetUrlCallback) end function DdzGameOverView:onEnter() DdzGameOverView.super.onEnter() setShowCountAll(true) stopBGMusic() end function DdzGameOverView:onExit() DdzGameOverView.super.onExit(self) setShowCountAll(false) end function DdzGameOverView:createItem( info ) info.totalScore = tonumber(info.totalScore) local node = loadUI("pk_zgwrddz/res/ui/ui_room/ui_wrddz_dajuitem.ui") setPlayerHeadImage(info.userId, info.headimgurl, node.Items.imgHead) node.Items.txtNick:setString(getSubStringNickname(info.nickname or "")) node.Items.txtID:setString("ID:"..info.userId) --显示隐藏游戏内选手id(主办人和管理员不限制,只针对海选赛) -- todo lwq -- begin local ClubDefine = require("luaScript.Protocol.Club.ClubDefine") if app.club_php.clubID and app.club_php.clubID ~= 0 then if app.club_php:getCestIsOpen(app.club_php.clubID) then --隐私数据 local clubInfo = app.club_php.clubList[app.club_php.clubID] self.cliext = clubInfo.groupext and clubInfo.groupext.cliext if not self.cliext or not self.cliext.is_hideUid or (self.cliext and self.cliext.is_hideUid == 1) then if clubInfo.role == ClubDefine.Job.Creator or clubInfo.role == ClubDefine.Job.Manager then node.Items.txtID:setVisible(true) else node.Items.txtID:setVisible(false) end end end end if info.userId == tonumber(app.user.loginInfo.uid) then node.Items.txtID:setVisible(true) end -- end node.Items.imgBest:setVisible(info.isBigWin and info.totalScore>0) node.Items.imgHost:setVisible(info.isHost) node.Items.imgHost:setVisible(false)--隐藏房主标签 --"extString" = "{"bombTimes":0,"loseTimes":0,"maxScore":3,"winTimes":2}" local extData = json.decode(info.extString) --[[node.Items.txtDjzgfs_1:setString(""..extData.maxScore) node.Items.txtDczds_1:setString(""..extData.bombTimes) node.Items.txtSyjs_1:setString(string.format("%d/%d", extData.loseTimes , extData.winTimes))--]] --local countInfo = json.decode(info.countInfo) --node.Items.txtDiamond:setText("-"..countInfo.DeInfo) node.Items.txt_ypcs_num:setText(""..extData.wintimes) node.Items.txt_dzcs_num:setText(""..extData.lordtimes) node.Items.txt_zcls_num:setText(""..extData.maxwintimes) if info.totalScore > 0 then node.Items.txtTotalScore:setString("+"..info.totalScore) node.Items.ImageView_light:setVisible(info.isBigWin) else node.Items.txtTotalScore:setFntFile("res/fonts/dt_jian_num.fnt") node.Items.txtTotalScore:setString(""..info.totalScore) node.Items.ImageView_light:setVisible(false) end if self._data.stopFlag == 9 or self._data.stopFlag == 8 then--解散游戏 local jiesaninfo = { [0] = "超时解散", [1] = "申请解散", [2] = "同意解散", [3] = "拒绝", [4] = "系统解散", } if extData.jiesan and extData.jiesan >= 0 then node.Items.txt_jiesanInfo:setText(jiesaninfo[extData.jiesan]) end else node.Items.txt_jiesanInfo:setVisible(false) end return node end function DdzGameOverView:test() local data = {{}, {}, {}} local dltWidth = 1273/#data for i,v in ipairs(data) do local item = GameOverItem:new(v) if i==1 then item:setPosition(cc.p((i-1)*dltWidth+dltWidth/2, 225)) elseif i==3 then else item:setPosition(cc.p((i-1)*dltWidth+dltWidth/2, 225)) end self.ui.Items.Layout_items:addChild(item) end end --- -- 初始化大结算再来一局 -- @return -- function DdzGameOverView:initPlayGameAgain () local roomInfo = app.room.roomInfo or {}; local gameId = roomInfo.gameId or app.gameId if dd.IClub.isInClub() and roomInfo.nShowTableId then local inviteList = {} for k,v in pairsByKeys(roomInfo.memberList) do if tonumber(v.nUserId) ~= app.user.loginInfo.uid then table.insert(inviteList, v.nUserId) end end local strInvite = Functions.getRuleStrByClubInvite() local btnPlayAgain = self.ui.Items.Button_PlayAgain dd.IPlayGameAgain.bindPlayAgainButton(btnPlayAgain, gameId, strInvite, inviteList, function () -- 初始化成功后干嘛干嘛 local visible = btnPlayAgain:isVisible() self.ui.Items.Layout_Button_PlayAgain:setVisible(visible) if self.ui.Items.Layout_Buttons then self.ui.Items.Layout_Buttons:requestDoLayout() self.ui.Items.Layout_Buttons:doLayout() end end) --绑定消息通知回调 self:bindEvent(app.club_php , GAME_EVENT.CLUB_INVITE , handler(self , self.onClubInviteEvent)) else logD("DdzGameOverView:initPlayGameAgain", "不在亲友圈或桌子id为空,不能进行再来一局操作") self.ui.Items.Layout_Button_PlayAgain:setVisible(false) self.ui.Items.Layout_Buttons:requestDoLayout() self.ui.Items.Layout_Buttons:doLayout() end end --- -- 监听亲友圈邀请信息 -- @param event -- @return -- function DdzGameOverView:onClubInviteEvent(event) dd.IPlayGameAgain.showClubInviteDialog(event, nil, nil) end return DdzGameOverView