178 lines
6.4 KiB
Lua
178 lines
6.4 KiB
Lua
---
|
||
--- Created by 谌建军.
|
||
--- DateTime: 2017/12/19 11:05
|
||
---
|
||
require("Game.View.ResultView")
|
||
|
||
local EXResultView = {}
|
||
|
||
local M = EXResultView
|
||
|
||
function EXResultView.new(root, data, over, win_seat)
|
||
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, over, win_seat)
|
||
return self
|
||
end
|
||
|
||
function M:init(url, data, over, win_seat)
|
||
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_nextRound').onClick:Set(function()
|
||
if over == 0 then
|
||
local _gamectr = ControllerManager.GetController(GameController)
|
||
_gamectr:ConformToNextGame()
|
||
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)
|
||
|
||
--处理win_seat
|
||
local temp_win_seat = {}
|
||
for i, v in ipairs(win_seat) do
|
||
temp_win_seat[v] = 1
|
||
end
|
||
win_seat = temp_win_seat
|
||
self._view:GetController('win').selectedIndex = win_seat[room.self_player.seat] and 1 or 0
|
||
|
||
local over0List = self._view:GetChild('list_over0')
|
||
table.sort(data, function(a, b)
|
||
return a.ranking < b.ranking
|
||
end)
|
||
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('cardScore').text = info.roundCardScore
|
||
obj:GetChild('bompScore').text = info.roundBonusScore
|
||
obj:GetChild('score').text = info.winscore > 0 and string.format("+%d", info.winscore) or info.winscore
|
||
end
|
||
over0List.numItems = #data
|
||
|
||
if over == 1 or (over == 2 and room.curren_round > 0) then
|
||
self._view:GetChild('text_roomID').text = room.room_id
|
||
self._view:GetChild('text_time').text = os.date('%m-%d %H:%M', os.time())
|
||
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)
|
||
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
|
||
|
||
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 = string.format("标识:%s", playerInfo.self_user.account_id)
|
||
local detailList = view:GetChild('list_detail')
|
||
self:FillDetailChild(detailList:AddItemFromPool(), "炸弹数", info.settle_log.boomnum)
|
||
self:FillDetailChild(detailList:AddItemFromPool(), "胜局",
|
||
string.format("%d赢%d输", info.settle_log.winnum, room.room_config.Times - info.settle_log.winnum))
|
||
if info.total_score > 0 then
|
||
view:GetController('win').selectedIndex = 1
|
||
view:GetChild('text_winScore').text = string.format("+%s", info.total_score)
|
||
else
|
||
view:GetController('win').selectedIndex = 0
|
||
view:GetChild('text_loseScore').text = info.total_score
|
||
end
|
||
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, title, value)
|
||
view:GetChild('text_title').text = title
|
||
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
|