--- --- Created by 谌建军. --- DateTime: 2017/12/19 11:05 --- require("Game.View.ResultView") local RunFast_ResultView = {} local M = RunFast_ResultView function RunFast_ResultView.new(root, data, roomid, over, win_seat, dissolve, remaincards) setmetatable(M, { __index = ResultView }) local self = setmetatable({}, { __index = M }) self.class = "RunFast_ResultView" self._currenIndex = 0 self._close_zone = false self._root_runFast = root self._gamectr = ControllerManager.GetController(GameController) self:init("ui://Extend_Poker_RunFastNew/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 ViewManager.ChangeView(ViewManager.View_Lobby) end ------------------ --只有一人直接退,有两人才进正常结算 if not over and #data == 1 then ViewManager.ChangeView(ViewManager.View_Lobby) end local btn_confirm = self._view:GetChild('btn_confirm') btn_confirm.onClick:Add( function() local _gamectr = ControllerManager.GetController(GameController) _gamectr:ConformToNextGame() self:Destroy() end ) local btn_Show1 = self._view:GetChild('btn_Show1') btn_Show1.onClick:Set(function() self._view:GetController('over').selectedIndex = 1 end) self._view:GetChild('btn_closeRound').onClick:Set(function() ViewManager.ChangeView(ViewManager.View_Lobby) end) local bgWindow = self._view:GetChild('bgWindow') if win_seat == room.self_player.seat then bgWindow.text = "胜利" bgWindow:GetController('bianhui').selectedIndex = 0 else bgWindow.text = "失败" bgWindow:GetController('bianhui').selectedIndex = 1 end -- self._view:GetController('win').selectedIndex = win_seat == room.self_player.seat and 1 or 0 local rt = 1 if room.hpOnOff == 1 then rt = room.score_times end 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('piao').text = info.piao < 0 and 0 or info.piao local roundScore = info.winCardScore local jifen = "" if roundScore >= 0 then jifen = "+" .. roundScore else jifen = "" .. roundScore end jifen = jifen .. " " local tili = "" if room.hpOnOff > 0 then local need = roundScore * rt tili = "(" if roundScore > 0 then tili = tili .. "+" .. tostring(need) else tili = tili .. tostring(need) end tili = tili .. ")" end obj:GetChild('score').text = jifen .. tili local list_residue = obj:GetChild('list_residue') list_residue:RemoveChildrenToPool() for i, v in ipairs(info.handCards) do local rc = list_residue:AddItemFromPool() rc.icon = string.format("ui://Extend_Poker_RunFastNew/%s", v) rc:GetController('choose').selectedIndex = 0 end for i, v in ipairs(info.outCards) do local rc = list_residue:AddItemFromPool() rc.icon = string.format("ui://Extend_Poker_RunFastNew/%s", v) rc:GetController('choose').selectedIndex = 1 end end over0List.numItems = #data if over == 1 or (over == 2 and room.curren_round > 0) then self._view:GetController('lastRound').selectedIndex = 1 self._view:GetChild('txt_room_id').text = '房号:' .. roomid self._view:GetChild('txt_game_name').text = room.room_config:GetGameName() self._view:GetChild('txt_game_data').text = os.date('%Y-%m-%d %H:%M', os.time()) local str_roominfo = string.gsub(room.room_config:GetDes(), '\r', '') self._view:GetChild('txt_play').text = str_roominfo for i = 1, #data do local info = data[i] local playerInfo = room:GetPlayerBySeat(info.seat) self:FillPlayerInfoEnd(self._view:GetChild(string.format("comp_playerInfo%d_over1", i)), info, playerInfo, rt, bgWindow) end local list_residue = self._view:GetChild('list_residue') list_residue:RemoveChildrenToPool() for i, v in ipairs(remaincards) do local rc = list_residue:AddItemFromPool() rc.icon = string.format("ui://Extend_Poker_RunFastNew/%s", v) 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 local btn_continue_game = self._view:GetChild('btn_continue_game') if btn_continue_game then local gid = room.group_id if gid ~= 0 then btn_continue_game.visible = true local pid = room.room_config.pid local game_id = room.game_id btn_continue_game.onClick:Set( function() self:ContinueGame(gid, pid, game_id) end ) end end end function M:FillPlayerInfoEnd(view, info, playerInfo, rt,bgWindow) local room = DataManager.CurrenRoom 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 local detailList = view:GetChild('list_detail') self:FillDetailChild(detailList:AddItemFromPool(), "赢局数:", info.settle_log.winnum) self:FillDetailChild(detailList:AddItemFromPool(), "打出炸弹数:", info.settle_log.boomnum) self:FillDetailChild(detailList:AddItemFromPool(), "春天次数:", info.settle_log.springnum) self:FillDetailChild(detailList:AddItemFromPool(), "当局最高分:", info.settle_log.maxscore * rt) view:GetChild('text_daniao').text = info.daniao view:GetChild('text_toltalScore').text = info.total_score view:GetChild('text_score').text = info.total_score - info.daniao view:GetController('win').selectedIndex = info.total_score >= 0 and 1 or 0 if info.seat == room.self_player.seat and info.total_score >= 0 then bgWindow.text = "胜利" bgWindow:GetController('bianhui').selectedIndex = 0 else bgWindow.text = "失败" bgWindow:GetController('bianhui').selectedIndex = 1 end end function M:FillDetailChild(view, index, value) view:GetChild('text_title').text = 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