-- 房间设置界面 local RoomDaJuView = class("RoomDaJuView_53", cc.UIView) local Functions = require("pk_nanchongdoudizhu.luaScript.Functions_53") function RoomDaJuView:ctor(response) RoomDaJuView.super.ctor(self) self.response = response end function RoomDaJuView:onEnter() RoomDaJuView.super.onEnter(self) local ui = loadUI("pk_nanchongdoudizhu/res/ui/ui_fangjian/doudizhu_ui_daJu.ui") self:addChild(ui) self.ui = ui -- 分享战绩 self.ui.Items.Button_Share:registerClick(handler(self , self.onClickShare)) -- 结束游戏 self.ui.Items.Button_Over:registerClick(handler(self , self.onClickOver)) if isReviewVersion() then self.ui.Items.Button_Share:setVisible(false) end end function RoomDaJuView:updateView(data) --显示 self:setVisible(true) --更新房间号 self.ui.Items.Text_RoomId:setText("房号: " .. app.room.roomInfo.nShowTableId) --更新局数 self.ui.Items.Text_JuShu:setText(string.format("%02d / %02d 局", app.room.roomInfo.nGameStartCount, app.room.roomInfo.nTotalGameNum)) --更新时间 self.ui.Items.Text_SystemTime:setText(getTimeString()) --规则 self.ui.Items.Text_GameRules:setText(Functions.getRuleStr()) --更新玩家信息 self:updatePlayer(data) end function RoomDaJuView:updatePlayer(data) --隐藏所有玩家 for i = 1, 4 do local player = self.ui.Items["Layout_Player_" .. i] if player then player:setVisible(false) end end local maxScore = 0 for _,v in pairs(data.memberList) do v.nTotalScore = tonumber(v.nTotalScore) if v.nTotalScore > maxScore then maxScore = v.nTotalScore end end --更新玩家数据 for k,v in pairs(data.memberList) do local viewId = app.room:getViewIdByUserId(v.nUserId) local player = self.ui.Items["Layout_Player_" .. viewId] local userInfo = json.decode(v.userInfo) if player then v.nTotalScore = tonumber(v.nTotalScore) --显示玩家信息 player:setVisible(true) --更新头像 local head = self.ui.Items["Image_Head_" .. viewId] if head then setPlayerHeadImage(v.nUserId, userInfo.headimgurl, head) end --名字 local name = self.ui.Items["Text_Name_" .. viewId] if name then name:setText("" .. userInfo.nickname) end --玩家id local userId = self.ui.Items["Text_UserId_" .. viewId] if userId then userId:setText("" .. v.nUserId) --显示隐藏游戏内选手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 userId:setVisible(true) else userId:setVisible(false) end end end end if v.nUserId == tonumber(app.user.loginInfo.uid) then userId:setVisible(true) end -- end end --分数 local score = self.ui.Items["Text_Score_" .. viewId] if score then if v.nTotalScore > 0 then score:setText("+" .. v.nTotalScore) else score:setText("" .. v.nTotalScore) end end --更新背景 local bg = self.ui.Items["Image_Bg_" .. viewId] if bg then if v.nTotalScore >= 0 then bg:loadTexture("pk_nanchongdoudizhu/res/ui/zy_fangjian/doudizhu_daju/doudizhu_daju_winbg.png") else bg:loadTexture("pk_nanchongdoudizhu/res/ui/zy_fangjian/doudizhu_daju/doudizhu_daju_losebg.png") end end --大赢家 local banker = self.ui.Items["Image_MaxWin_" .. viewId] if banker then banker:setVisible(maxScore > 0 and maxScore <= v.nTotalScore) end end end self.ui.Items.Layout_Players:requestDoLayout() self.ui.Items.Layout_Players:doLayout() end -- 分享 function RoomDaJuView:onClickShare() playBtnEffect() function callbackEx(ret, fileName) if tonumber(ret) == 1 then local info = {} info.contentType = "image" info.image = fileName info.imageWidth = 800 local gamerule = nil local roomInfo = app.room.roomInfo if roomInfo.strGameInfo then local jsonInfo = json.decode(roomInfo.strGameInfo) if jsonInfo then gamerule = jsonInfo.gamerule end end local rulename = "" if gamerule then rulename = " - " .. getSubGameRuleName(app.gameId, gamerule) end local gameName = getSubGameName(app.gameId) .. rulename info.copyData = { type = 1, gameName = gameName or "", tableId = app.room.roomInfo.nShowTableId, userInfos = {}, } info.isShareZhanjiUrl = true for nUserId,totalData in pairsByKeys(self.response) do local userInfo = app.room:getUserInfo(nUserId) --昵称 local nickname = userInfo.nickname or "" local totalScore = totalData.nTotalScore table.insert(info.copyData.userInfos, { nickname = nickname, totalScore = totalScore }) end local view = import("luaScript.Views.Main.ShareView"):new(info) view:setAnchorPoint(cc.p(0.5, 0.5)) app:showWaitDialog(view) else showTooltip("截图保存失败") end end if isWin32Platform() then callbackEx(1, "testName") else local fileNameEx = cc.FileUtils:getInstance():getWritablePath() .. tostring(app.room.roomInfo.nShowTableId) .. "_screen.jpg" cc.FileUtils:getInstance():screenToFile(fileNameEx, function(retEx) callbackEx(retEx, fileNameEx) end) end end -- 确认 function RoomDaJuView:onClickOver() playBtnEffect() app.room:dispatchEvent({name = "onGameOverResponse"}) self:removeFromParent() app:gotoView(import("luaScript.Views.Main.MainView"):new(app.gameId, app.room.roomInfo.nShowTableId)) end return RoomDaJuView