396 lines
14 KiB
Lua
396 lines
14 KiB
Lua
|
|
-- 开桌统计
|
||
|
|
local GroupMngRoomStatView = {}
|
||
|
|
|
||
|
|
local M = GroupMngRoomStatView
|
||
|
|
|
||
|
|
function GroupMngRoomStatView.new(gid)
|
||
|
|
local self = M
|
||
|
|
self.class = "GroupMngRoomStatView"
|
||
|
|
self.group_id = gid
|
||
|
|
self:InitView()
|
||
|
|
return self
|
||
|
|
end
|
||
|
|
|
||
|
|
function M:initData()
|
||
|
|
self.lst_record.numItems = 0
|
||
|
|
self.record_data = {}
|
||
|
|
self.lst_player_record.numItems = 0
|
||
|
|
self.player_record_data = {}
|
||
|
|
self.qid = 0
|
||
|
|
self._view:GetController("search").selectedIndex = 0
|
||
|
|
self._view:GetController("record").selectedIndex = 0
|
||
|
|
self._view:GetChild("tex_id").text = ""
|
||
|
|
self:GetRecordData(0, self.qid)
|
||
|
|
end
|
||
|
|
|
||
|
|
function M:InitView()
|
||
|
|
self._view = UIPackage.CreateObjectFromURL("ui://NewGroup/View_GroupStat")
|
||
|
|
|
||
|
|
self.record_data = {} --回放数据
|
||
|
|
self.player_record_data = {} --指定玩家的回放数据
|
||
|
|
self.qid = 0 --查询玩家id
|
||
|
|
|
||
|
|
self.lst_record_find = self._view:GetChild("lst_record_find")
|
||
|
|
self.lst_record_find:SetVirtual()
|
||
|
|
self.lst_record_find.itemRenderer = function(index, obj)
|
||
|
|
self:OnRenderRecordItem1(index, obj)
|
||
|
|
end
|
||
|
|
|
||
|
|
self.lst_record = self._view:GetChild("lst_record")
|
||
|
|
self.lst_record:SetVirtual()
|
||
|
|
self.lst_record.itemRenderer = function(index, obj)
|
||
|
|
self:OnRenderRecordItem(index, obj)
|
||
|
|
end
|
||
|
|
self.lst_record.scrollPane.onPullUpRelease:Set(function()
|
||
|
|
self:GetRecordData(self.lst_record.numItems)
|
||
|
|
end)
|
||
|
|
|
||
|
|
self.lst_player_record = self._view:GetChild("lst_player_record")
|
||
|
|
self.lst_player_record:SetVirtual()
|
||
|
|
self.lst_player_record.itemRenderer = function(index, obj)
|
||
|
|
self:OnRenderPlayerRecordItem(index, obj)
|
||
|
|
end
|
||
|
|
self.lst_player_record.scrollPane.onPullUpRelease:Set(function()
|
||
|
|
self:GetRecordData(self.lst_player_record.numItems, self.qid)
|
||
|
|
|
||
|
|
end)
|
||
|
|
|
||
|
|
self._view:GetChild("btn_search").onClick:Set(function()
|
||
|
|
local qid = self._view:GetChild("tex_id").text
|
||
|
|
local rtype = self._view:GetChild("cb_type").value
|
||
|
|
if (qid == "" and rtype == "1") or (string.len(qid) < 6 and rtype == "2") then
|
||
|
|
ViewUtil.ErrorTip(nil, "请输入正确的ID")
|
||
|
|
return
|
||
|
|
end
|
||
|
|
if rtype == "1" then
|
||
|
|
self.lst_player_record.numItems = 0
|
||
|
|
self.player_record_data = {}
|
||
|
|
self.qid = tonumber(qid)
|
||
|
|
self:GetRecordData(0, self.qid)
|
||
|
|
else
|
||
|
|
self:GetRecordByRoomid()
|
||
|
|
end
|
||
|
|
end)
|
||
|
|
self._view:GetChild("btn_search_back").onClick:Set(function()
|
||
|
|
self.qid = 0
|
||
|
|
self.player_record_data = {}
|
||
|
|
self.lst_player_record.numItems = 0
|
||
|
|
self.isFindCode=false
|
||
|
|
|
||
|
|
end)
|
||
|
|
end
|
||
|
|
|
||
|
|
function M:GetRecordData(index, qid)
|
||
|
|
qid = qid or 0
|
||
|
|
ViewUtil.ShowModalWait()
|
||
|
|
local fgCtr = ControllerManager.GetController(NewGroupController)
|
||
|
|
fgCtr:FG_GetGroupRecord(self.group_id, GetPlatform(), qid, index, 6, function(res)
|
||
|
|
printlog("ccccccccccccccccccccccccccccccccccccc")
|
||
|
|
pt(res)
|
||
|
|
if self._is_destroy then
|
||
|
|
return
|
||
|
|
end
|
||
|
|
ViewUtil.CloseModalWait()
|
||
|
|
if res.ReturnCode ~= 0 then
|
||
|
|
ViewUtil.ErrorTip(res.ReturnCode, "获取回放数据失败")
|
||
|
|
else
|
||
|
|
local ctr_search = self._view:GetController("search")
|
||
|
|
local records = res.Data.records
|
||
|
|
if qid == 0 then
|
||
|
|
for i = 1, #records do
|
||
|
|
self.record_data[#self.record_data + 1] = records[i]
|
||
|
|
end
|
||
|
|
self.lst_record.numItems = #self.record_data
|
||
|
|
if ctr_search.selectedIndex ~= 0 then
|
||
|
|
ctr_search.selectedIndex = 0
|
||
|
|
end
|
||
|
|
else
|
||
|
|
for i = 1, #records do
|
||
|
|
self.player_record_data[#self.player_record_data + 1] = records[i]
|
||
|
|
end
|
||
|
|
self.lst_player_record.numItems = #self.player_record_data
|
||
|
|
ctr_search.selectedIndex = 2
|
||
|
|
end
|
||
|
|
end
|
||
|
|
end)
|
||
|
|
end
|
||
|
|
|
||
|
|
function M:FillRecordItem(data, obj)
|
||
|
|
local game_id = data.game_id
|
||
|
|
local room_id = data.room_id
|
||
|
|
local create_time = data.create_time
|
||
|
|
local room_type_str = data.game_info.name
|
||
|
|
local time =tonumber(create_time)
|
||
|
|
local room_time_str = os.date("%Y-%m-%d %H:%M:%S", time)
|
||
|
|
local totalScore = json.decode(data.totalScore)
|
||
|
|
local hpOnOff = data.hpOnOff
|
||
|
|
local hpType = data.game_info.hpType
|
||
|
|
local player_list = {}
|
||
|
|
for i = 1, #totalScore do
|
||
|
|
local p = totalScore[i]
|
||
|
|
player_list[i] = {}
|
||
|
|
player_list[i].id = p.accId
|
||
|
|
local score = p.score
|
||
|
|
if hpOnOff == 1 and hpType > 1 then
|
||
|
|
score = score / 10
|
||
|
|
end
|
||
|
|
player_list[i].score = score
|
||
|
|
player_list[i].house = 0
|
||
|
|
player_list[i].nick = p.nick
|
||
|
|
end
|
||
|
|
local play_name = DataManager.groups:get(self.group_id):getPlayName(data.groupPid)
|
||
|
|
|
||
|
|
obj:GetChild("tex_time").text = room_time_str
|
||
|
|
obj:GetChild("tex_roomid").text = room_id
|
||
|
|
obj:GetChild("tex_times").text = d2ad(data.hp_times).."倍"
|
||
|
|
obj:GetChild("tex_game").text = play_name
|
||
|
|
local lst_total = obj:GetChild("lst_total")
|
||
|
|
lst_total:RemoveChildrenToPool()
|
||
|
|
local ids = {}
|
||
|
|
for j=1,#totalScore do
|
||
|
|
local titem = lst_total:AddItemFromPool()
|
||
|
|
local trdata = totalScore[j]
|
||
|
|
titem:GetChild("tex_name").text = ViewUtil.stringEllipsis(trdata.nick)
|
||
|
|
titem:GetChild("tex_id").text = trdata.accId and ("ID:"..trdata.accId) or ""
|
||
|
|
|
||
|
|
table.insert( ids,trdata.accId )
|
||
|
|
local score = trdata.score
|
||
|
|
if trdata.hp == nil then
|
||
|
|
if hpOnOff == 1 and hpType > 1 then
|
||
|
|
score = score / 10
|
||
|
|
end
|
||
|
|
else
|
||
|
|
score = d2ad(trdata.hp)
|
||
|
|
end
|
||
|
|
|
||
|
|
titem:GetChild("tex_score").text = score
|
||
|
|
|
||
|
|
if score >= 0 then
|
||
|
|
titem:GetController("num_color").selectedIndex = 0
|
||
|
|
else
|
||
|
|
titem:GetController("num_color").selectedIndex = 1
|
||
|
|
end
|
||
|
|
end
|
||
|
|
|
||
|
|
if #totalScore >= 6 then
|
||
|
|
obj:GetController("person_num").selectedIndex = 1
|
||
|
|
else
|
||
|
|
obj:GetController("person_num").selectedIndex = 0
|
||
|
|
end
|
||
|
|
|
||
|
|
obj:GetChild("btn_screenshot").onClick:Set(function()
|
||
|
|
self:OnShareScreenShot(room_id, room_type_str, room_time_str, totalScore, hpOnOff, hpType)
|
||
|
|
end)
|
||
|
|
|
||
|
|
obj:GetChild("btn_share").onClick:Set(function()
|
||
|
|
ShareChatRoom(room_id, tostring(os.time()), data.round, room_type_str, self.group_id, player_list)
|
||
|
|
end)
|
||
|
|
obj.onClick:Set(function()
|
||
|
|
self:OnShowRecordInfo(data,ids)
|
||
|
|
end)
|
||
|
|
end
|
||
|
|
|
||
|
|
function M:OnRenderRecordItem(index, obj)
|
||
|
|
local data = self.record_data[index + 1]
|
||
|
|
self:FillRecordItem(data, obj)
|
||
|
|
end
|
||
|
|
|
||
|
|
function M:OnRenderRecordItem1(index, obj)
|
||
|
|
local data=self.tempRec[index+1]
|
||
|
|
self:FillRecordItem(data, obj)
|
||
|
|
end
|
||
|
|
|
||
|
|
function M:OnRenderPlayerRecordItem(index, obj)
|
||
|
|
local data = self.player_record_data[index + 1]
|
||
|
|
self:FillRecordItem(data, obj)
|
||
|
|
end
|
||
|
|
|
||
|
|
|
||
|
|
function M:GetRecordByRoomid()
|
||
|
|
local qid = self._view:GetChild("tex_id").text
|
||
|
|
ViewUtil.ShowModalWait()
|
||
|
|
local fgCtr = ControllerManager.GetController(NewGroupController)
|
||
|
|
fgCtr:FG_GetRecordByRoomid(self.group_id, qid, GetPlatform(), function(res)
|
||
|
|
if self._is_destroy then
|
||
|
|
return
|
||
|
|
end
|
||
|
|
ViewUtil.CloseModalWait()
|
||
|
|
if res.ReturnCode ~= 0 then
|
||
|
|
ViewUtil.ErrorTip(res.ReturnCode, "获取回放数据失败")
|
||
|
|
else
|
||
|
|
if not res.Data.is_rec then
|
||
|
|
ViewUtil.ErrorTip(nil, "没有找到回放")
|
||
|
|
return
|
||
|
|
end
|
||
|
|
self.tempRec=res.Data.rec
|
||
|
|
self.lst_record_find.numItems = #res.Data.rec
|
||
|
|
|
||
|
|
self._view:GetController("search").selectedIndex = 1
|
||
|
|
end
|
||
|
|
end)
|
||
|
|
end
|
||
|
|
|
||
|
|
function M:OnShareScreenShot(room_id, room_type_str, room_time_str, totalScore, hpOnOff, hpType)
|
||
|
|
ViewUtil.ShowModalWait(self._view, "正在分享...")
|
||
|
|
UIPackage.AddPackage("base/rank/ui/Rank")
|
||
|
|
local result_view = UIPackage.CreateObjectFromURL("ui://Rank/ResultView")
|
||
|
|
result_view.visible = false
|
||
|
|
self._view:AddChild(result_view)
|
||
|
|
result_view.x = -308
|
||
|
|
result_view.y = -47
|
||
|
|
result_view:GetChild("tex_roomnum").text = "房间号:" .. room_id .. " " .. room_type_str
|
||
|
|
result_view:GetChild("tex_data").text = room_time_str
|
||
|
|
result_view:GetChild("btn_confirm").onClick:Set(function() result_view:Dispose() end)
|
||
|
|
local lst_p = result_view:GetChild("list_result")
|
||
|
|
local load_head_num = #totalScore
|
||
|
|
for j = 1, #totalScore do
|
||
|
|
local p = totalScore[j]
|
||
|
|
local item = lst_p:AddItemFromPool()
|
||
|
|
item:GetChild("name").text = p.nick
|
||
|
|
local score = p.score
|
||
|
|
if hpOnOff == 1 and hpType > 1 then
|
||
|
|
score = score / 10
|
||
|
|
end
|
||
|
|
item:GetChild("score").text = score
|
||
|
|
if score < 0 then item:GetController("di").selectedIndex = 1 end
|
||
|
|
if p.portrait and p.portrait ~= "" then
|
||
|
|
ImageLoad.Load(p.portrait, item:GetChild("n9")._iconObject, self.class, function( ... )
|
||
|
|
load_head_num = load_head_num - 1
|
||
|
|
end)
|
||
|
|
else
|
||
|
|
load_head_num = load_head_num - 1
|
||
|
|
end
|
||
|
|
end
|
||
|
|
coroutine.start(function ( ... )
|
||
|
|
local left_time = 4
|
||
|
|
while (true) do
|
||
|
|
if load_head_num == 0 or left_time == 0 then
|
||
|
|
result_view.visible = true
|
||
|
|
coroutine.wait(0.2)
|
||
|
|
ShareScreenShotWithOption(function()
|
||
|
|
result_view:Dispose()
|
||
|
|
end)
|
||
|
|
ViewUtil.CloseModalWait()
|
||
|
|
break
|
||
|
|
end
|
||
|
|
coroutine.wait(1)
|
||
|
|
left_time = left_time - 1
|
||
|
|
end
|
||
|
|
end)
|
||
|
|
end
|
||
|
|
|
||
|
|
function M:OnShowRecordInfo(rdata,ids)
|
||
|
|
local ctr_record = self._view:GetController("record")
|
||
|
|
ctr_record.selectedIndex = 1
|
||
|
|
|
||
|
|
local lst_recordInfo = self._view:GetChild("lst_recordInfo")
|
||
|
|
lst_recordInfo:RemoveChildrenToPool()
|
||
|
|
-- lst_recordInfo.scrollPane.currentPageX = 0
|
||
|
|
local round_count = tonumber(rdata.round)
|
||
|
|
local game_id = rdata.game_info.game_id
|
||
|
|
local playback_id = rdata.military_id
|
||
|
|
local hpOnOff = rdata.hpOnOff
|
||
|
|
local hpType = rdata.game_info.hpType
|
||
|
|
local play_name = DataManager.groups:get(self.group_id):getPlayName(rdata.groupPid)
|
||
|
|
for i = 1,round_count do
|
||
|
|
local item = lst_recordInfo:AddItemFromPool()
|
||
|
|
item:GetChild("tex_num").text = tostring(i)
|
||
|
|
item:GetChild("tex_game").text = play_name
|
||
|
|
item:GetChild("tex_times").text = d2ad(rdata.hp_times).."倍"
|
||
|
|
item:GetChild("tex_roomid").text = rdata.room_id
|
||
|
|
local round_score_str = rdata["round_"..i]
|
||
|
|
local round_score_item = json.decode(round_score_str)
|
||
|
|
local lst_total = item:GetChild("lst_total")
|
||
|
|
lst_total:RemoveChildrenToPool()
|
||
|
|
for k=1,#round_score_item do
|
||
|
|
local titem = lst_total:AddItemFromPool()
|
||
|
|
local trdata = round_score_item[k]
|
||
|
|
titem:GetChild("tex_name").text = ViewUtil.stringEllipsis(trdata.nick)
|
||
|
|
titem:GetChild("tex_id").text = "ID:".. ids[k]
|
||
|
|
local score = trdata.score
|
||
|
|
if trdata.hp == nil then
|
||
|
|
if hpOnOff == 1 and hpType > 1 then
|
||
|
|
score = score / 10
|
||
|
|
end
|
||
|
|
else
|
||
|
|
score = d2ad(trdata.hp)
|
||
|
|
end
|
||
|
|
|
||
|
|
titem:GetChild("tex_score").text = score
|
||
|
|
end
|
||
|
|
|
||
|
|
if #round_score_item >= 6 then
|
||
|
|
item:GetController("person_num").selectedIndex = 1
|
||
|
|
else
|
||
|
|
item:GetController("person_num").selectedIndex = 0
|
||
|
|
end
|
||
|
|
|
||
|
|
local btn_play =item:GetChild("btn_play")
|
||
|
|
btn_play.onClick:Set(function()
|
||
|
|
local group = DataManager.groups:get(self.group_id)
|
||
|
|
if DataManager.SelfUser.playback[playback_id] ~= nil and DataManager.SelfUser.playback[playback_id][i] ~= nil then
|
||
|
|
local room = ExtendManager.GetExtendConfig(game_id):NewRoom()
|
||
|
|
DataManager.CurrenRoom = room
|
||
|
|
room.lev = group.lev
|
||
|
|
room.game_id = game_id
|
||
|
|
local extend = ExtendManager.GetExtendConfig(game_id)
|
||
|
|
extend:FillPlayBackData(DataManager.SelfUser.playback[playback_id][i])
|
||
|
|
if not room.self_player then
|
||
|
|
room.self_player = room:GetPlayerBySeat(1)
|
||
|
|
end
|
||
|
|
local main = self:GenaratePlayBack(ViewManager.View_PlayBack, game_id)
|
||
|
|
main._currentId = playback_id
|
||
|
|
main._currentRound = i
|
||
|
|
main._totalRound = tonumber(rdata.round)
|
||
|
|
main:FillRoomData(DataManager.SelfUser.playback[playback_id][i])
|
||
|
|
else
|
||
|
|
ViewUtil.ShowModalWait(self._view)
|
||
|
|
local _data = {}
|
||
|
|
_data["military_id"] = playback_id
|
||
|
|
_data["round"] = tostring(i)
|
||
|
|
local loddyCtr1 = ControllerManager.GetController(LoddyController)
|
||
|
|
loddyCtr1:RequestPlayBack(_data,function(code,data)
|
||
|
|
ViewUtil.CloseModalWait()
|
||
|
|
if code == 0 then
|
||
|
|
if DataManager.SelfUser.playback[playback_id] ~= nil then
|
||
|
|
DataManager.SelfUser.playback[playback_id][i] = data
|
||
|
|
else
|
||
|
|
local playback_data = {}
|
||
|
|
playback_data[i] = data
|
||
|
|
DataManager.SelfUser.playback[playback_id] = playback_data
|
||
|
|
end
|
||
|
|
|
||
|
|
local main = self:GenaratePlayBack(ViewManager.View_PlayBack, game_id)
|
||
|
|
main._currentId = playback_id
|
||
|
|
main._currentRound = i
|
||
|
|
main._totalRound = tonumber(rdata.round)
|
||
|
|
main:FillRoomData(data)
|
||
|
|
main._room.lev = group.lev
|
||
|
|
elseif code == 25 then
|
||
|
|
ViewUtil.ErrorTip(-1, "回放未找到!")
|
||
|
|
-- btn_play_back.grayed = true
|
||
|
|
end
|
||
|
|
end, rdata.game_info)
|
||
|
|
end
|
||
|
|
end)
|
||
|
|
end
|
||
|
|
end
|
||
|
|
|
||
|
|
function M:GenaratePlayBack(id, game_id, ...)
|
||
|
|
local tem =nil
|
||
|
|
local dview_class = nil
|
||
|
|
if not dview_class then
|
||
|
|
local exconfig = ExtendManager.GetExtendConfig(game_id)
|
||
|
|
dview_class = exconfig:GetView(id)
|
||
|
|
end
|
||
|
|
if not dview_class then
|
||
|
|
return
|
||
|
|
end
|
||
|
|
local arg = {...}
|
||
|
|
tem = dview_class.new(...)
|
||
|
|
tem.Id = id
|
||
|
|
tem:Show()
|
||
|
|
return tem
|
||
|
|
end
|
||
|
|
|
||
|
|
return M
|