|
- local PdkGameOverView = class("PdkGameOverView", cc.UIView)
- local GameOverItem = require("pk_paodekuai.luaScript.Views.Room.Node.PdkGameOverItem")
- --[[
- "onResponseGameOver" = {
- "players" = {
- 1 = {
- "extString" = "{"bombTimes":0,"loseTimes":2,"maxScore":0,"winTimes":0}"
- "totalScore" = -6
- "userId" = 1023546
- }
- 2 = {
- "extString" = "{"bombTimes":0,"loseTimes":0,"maxScore":3,"winTimes":2}"
- "totalScore" = 6
- "userId" = 1023544
- }
- }
- }
- ]]
- function PdkGameOverView:ctor( overData )
- self._data = overData
- local ui = loadUI("pk_paodekuai/res/ui/ui_room/ui_pdk_gameoverview.ui")
- self.ui = ui
- self:addChild(ui)
- self:initUi()
- self:setPlayerInfo()
- end
-
- function PdkGameOverView:initUi()
- self.ui.Items.btnShare:registerClick(handler(self , self.onClickShare))
- self.ui.Items.btnOk:registerClick(handler(self , self.onClickOk))
- if isReviewVersion() then
- self.ui.Items.Layout_4:setVisible(false)
- end
- self.ui.Items.txtRoomID:setString(string.format("房号:%06d", self._data.nShowTableId or 0))
- self.ui.Items.txtRoundNum:setString(string.format("%s", os.date("%m-%d %H:%M", os.time()) ))
- self.ui.Items.txtRoomRule:setString(string.format("%s", self._data.roomRule or ""))
- if #self._data.players == 2 then
- local shift = 40
- self.ui.Items.ImageView_card_1:setPositionX(134+shift)
- self.ui.Items.ImageView_card_2:setPositionX(1145-shift)
- end
- end
-
- function PdkGameOverView:setPlayerInfo()
- local maxUserId = self._data.players[1].userId
- local maxScore = self._data.players[1].totalScore
- maxScore = tonumber(maxScore)
- 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.userId == maxUserId
- v.isHost = v.userId == roomInfo.nRoomOwnedUid
- local item = self:createItem(v)
- self.ui.Items.Layout_items:addChild(item)
- end
- self.ui.Items.Layout_items:requestDoLayout();
- self.ui.Items.Layout_items:doLayout();
- end
-
- function PdkGameOverView:onClickShare( 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 = 1000
- info.thumbWidth = 100
- --app.plugin:shareGame(info)
- info.copyData={
- type=1,
- tableId=self._data.nShowTableId,
- userInfos={},
- gameId=36,
- }
- for nUserId,totalData in pairsByKeys(self._data.players) do
- local userInfo = app.room:getUserInfo(totalData.userId)
- --昵称
- local nickname = 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 PdkGameOverView:onClickOk( sender )
- playBtnEffect()
- --app:gotoView(import("luaScript.Views.Main.MainView"):new(GAME_IDS.PaoDeKuai))
- gotoMainView(GAME_IDS.PaoDeKuai)
- end
-
- function PdkGameOverView:onEnter()
- PdkGameOverView.super.onEnter()
- setShowCountAll(true)
- stopBGMusic()
- end
-
- function PdkGameOverView:onExit()
- PdkGameOverView.super.onExit(self)
- setShowCountAll(false)
- end
-
- function PdkGameOverView:createItem( info )
- info.totalScore = tonumber(info.totalScore)
- local node = loadUI("pk_paodekuai/res/ui/ui_room/ui_pdk_gameoveritem.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))
-
- if info.totalScore > 0 then
- node.Items.txtTotalScore:setString("+"..info.totalScore)
- node.Items.txtTotalScore:setColor(cc.c3b(212, 16, 16))
- node.Items.imgTotalTitle:loadTexture("pk_paodekuai/res/ui/zy_gameresult/pdk_gameresult_img_winbg.png", 0)
- else
- node.Items.txtTotalScore:setString(""..info.totalScore)
- node.Items.imgTotalTitle:loadTexture("pk_paodekuai/res/ui/zy_gameresult/pdk_gameresult_img_losebg.png", 0)
- end
- if self._data.stopFlag == 9 or self._data.stopFlag == 8 then--解散游戏
- local jiesanData = json.decode(self._data.stopResult)
- local jiesanLab = node.Items.txtID:getCopied()
- local jiesanPos = node.Items.txtID:getPosition()
- local config = jiesanLab:getFontConfig();
- config.fontSize = 18;
- config.texColor = cc.c4b(255,155,155,255)
- jiesanLab:setFontConfig(config);
- local jiesaninfo = {
- [0] = "超时解散",
- [1] = "申请解散",
- [2] = "同意解散",
- [3] = "拒绝",
- }
- if jiesanData and jiesanData[tostring(info.userId)] then
- jiesanLab:setPositionY(jiesanPos.y - 210)
- jiesanLab:setPositionX(jiesanPos.x)
- jiesanLab:setAnchorPoint(cc.p(0.5, 0.5))
- --jiesanLab:setColor(cc.c3b(255,0,0))
- if self._data.stopFlag == 9 then
- jiesanLab:setText(jiesaninfo[jiesanData[tostring(info.userId)]])
- elseif self._data.stopFlag == 8 then
- jiesanLab:setText("系统解散")
- end
- node.Items.Layout_player:addChild(jiesanLab)
- end
- end
- return node
- end
-
- function PdkGameOverView: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 PdkGameOverView
|