--- --- Created by 谌建军. --- DateTime: 2017/12/19 11:05 --- require("Game.View.ResultView") local EXResultView = {} local M = EXResultView function EXResultView.new(root, data, roomid, over, win_seat, dissolve, remaincards) setmetatable(M, { __index = ResultView }) local self = setmetatable({}, { __index = M }) self.class = "EXResultView" self._currenIndex = 0 self._close_zone = false self._root_runFast = root self._gamectr = ControllerManager.GetController(GameController) self:init("ui://Extend_Poker_DuoDuo/clearing_new", data, roomid, over, win_seat, dissolve, remaincards) print("=======================lingmengresult", data, roomid, over, win_seat, dissolve, remaincards) return self end function M:init(url, data, roomid, over, win_seat, dissolve, remaincards) ResultView.init(self, url, true) local room = DataManager.CurrenRoom self._view:GetController('over').selectedIndex = 0 if over == 2 and room.curren_round <= 0 then if room._flag_lobby then ViewManager.ChangeView(ViewManager.View_Lobby) else ViewManager.ChangeView(ViewManager.View_Family) end end ------------------ --只有一人直接退,有两人才进正常结算 if not over and #data == 1 then if room._flag_lobby then ViewManager.ChangeView(ViewManager.View_Lobby) else ViewManager.ChangeView(ViewManager.View_Family) end end self._view:GetChild('btn_over1Close').onClick:Set(function() if over == 0 then self:Close() else self._view:GetController('over').selectedIndex = 1 end end) self._view:GetChild('btn_nextRound').onClick:Set(function() if over == 0 then local _gamectr = ControllerManager.GetController(GameController) _gamectr:ConformToNextGame() -- self._root_runFast._ctr_inClear.selectedIndex = 0 self:Destroy() else self._view:GetController('over').selectedIndex = 1 end end) self.ClearReady = function() if over == 0 then local _gamectr = ControllerManager.GetController(GameController) _gamectr:ConformToNextGame() self._root_runFast:ClearOk() self:Destroy() else self._view:GetController('over').selectedIndex = 1 end end self._view:GetChild('btn_closeRound').onClick:Set(function() if room._flag_lobby then ViewManager.ChangeView(ViewManager.View_Lobby) else ViewManager.ChangeView(ViewManager.View_Family) end end) self._view:GetController('win').selectedIndex = win_seat == room.self_player.seat and 1 or 0 local over0List = self._view:GetChild('list_over0') over0List:SetVirtual() over0List.itemRenderer = function(index, obj) local info = data[index + 1] local playerInfo = room:GetPlayerBySeat(info.seat) obj:GetChild('name').text = playerInfo.self_user.nick_name obj:GetChild('residue').text = #info.handCards obj:GetChild('bomb').text = info.thisboomnum obj:GetChild('score').text = info.winscore > 0 and string.format("+%d", info.winscore) or info.winscore obj:GetController('chuntian').selectedIndex = info.chuntian and 1 or 0 end over0List.numItems = #data -- self._root_runFast._ctr_inClear.selectedIndex = 1 if over == 1 or (over == 2 and room.curren_round > 0) then local bigSeat = 0 local bigScore = 0 for i = 1, #data do if data[i].total_score > bigScore then bigSeat = i bigScore = data[i].total_score end end self._view:GetChild('text_roomID').text = room.room_id self._view:GetChild('text_time').text = os.date('%m-%d %H:%M', os.time()) self._view:GetChild('text_groupID').text = room.group_id or 0 self._view:GetController('num').selectedIndex = #data == 2 and 0 or 1 self._view:GetController('isgroup').selectedIndex = room.group_id ~= 0 and 1 or 0 for i = 1, #data do local info = data[i] local playerInfo = room:GetPlayerBySeat(info.seat) printlog("lingmeng clear", playerInfo.nick_name, info.total_score, i == bigSeat) self:FillPlayerInfoEnd(self._view:GetChild(string.format("comp_playerInfo%d_over1", i)), info, playerInfo, i == bigSeat) end coroutine.start(function() coroutine.wait(2) self._view:GetController('over').selectedIndex = 1 end) end local Btn_Share = self._view:GetChild('btn_shareRecord') if Btn_Share then Btn_Share.onClick:Set(function() self:SaveRenderTextureToPNG() end) end local Btn_Copy = self._view:GetChild('btn_copyRecord') if Btn_Copy then Btn_Copy.onClick:Set(function() local resultStr = "" if room.group_id ~= 0 then local group = DataManager.groups:get(room.group_id) resultStr = string.format("【%s】俱乐部,", group.name) end resultStr = string.format("%s%s\n", resultStr, room.game_info.name) for i = 1, #data do local info = data[i] local playerInfo = room:GetPlayerBySeat(info.seat) resultStr = string.format("%s%s\nID:%s【%s】\n", resultStr, playerInfo.self_user.nick_name, playerInfo.self_user.account_id, info.total_score) end resultStr = string.format("%s房号:%s 局数:%s/%s局\n结束时间:%s", resultStr, room.room_id, room.curren_round, room.room_config.Times, os.date("%Y-%m-%d %H:%M:%S", os.time())) ViewUtil.__openWx() GameApplication.Instance:CopyToClipboard(resultStr) end) end end function M:FillPlayerInfoEnd(view, info, playerInfo, bigWin) local room = DataManager.CurrenRoom self:FillPlayerHead(view:GetChild('comp_playerInfo'), playerInfo, bigWin) local detailList = view:GetChild('list_detail') self:FillDetailChild(detailList:AddItemFromPool(), 0, info.settle_log.maxscore) self:FillDetailChild(detailList:AddItemFromPool(), 1, info.settle_log.boomnum) self:FillDetailChild(detailList:AddItemFromPool(), 2, string.format("%d赢%d输", info.settle_log.winnum, room.room_config.Times - info.settle_log.winnum)) self:FillDetailChild(detailList:AddItemFromPool(), 3, info.total_score) end function M:FillPlayerHead(view, playerInfo, bigWin) ImageLoad.Load(playerInfo.self_user.head_url, view:GetChild('btn_head')._iconObject) view:GetChild('text_name').text = ViewUtil.stringEllipsis(playerInfo.self_user.nick_name) view:GetChild('text|_ID').text = playerInfo.self_user.account_id view:GetController('bigWin').selectedIndex = bigWin and 1 or 0 end function M:FillDetailChild(view, index, value) view:GetController('ShowTitle').selectedIndex = index view:GetChild('text_value').text = value end function M:SetDestroryCallback(fct) self._destoryCallback = fct end function M:Destroy() if self._destoryCallback then self._destoryCallback() end getmetatable(M).__index.Destroy(self) end return M