盟主观战可以查看双方

master
罗家炜 2025-06-21 22:58:29 +08:00
parent 61fc680b4a
commit af006a117c
5 changed files with 178 additions and 179 deletions

View File

@ -52,7 +52,6 @@ function M:InitView()
end end
self.lst_player_record.scrollPane.onPullUpRelease:Set(function() self.lst_player_record.scrollPane.onPullUpRelease:Set(function()
self:GetRecordData(self.lst_player_record.numItems, self.qid) self:GetRecordData(self.lst_player_record.numItems, self.qid)
end) end)
self._view:GetChild("btn_search").onClick:Set(function() self._view:GetChild("btn_search").onClick:Set(function()
@ -75,8 +74,7 @@ function M:InitView()
self.qid = 0 self.qid = 0
self.player_record_data = {} self.player_record_data = {}
self.lst_player_record.numItems = 0 self.lst_player_record.numItems = 0
self.isFindCode=false self.isFindCode = false
end) end)
end end
@ -120,7 +118,7 @@ function M:FillRecordItem(data, obj)
local room_id = data.room_id local room_id = data.room_id
local create_time = data.create_time local create_time = data.create_time
local room_type_str = data.game_info.name local room_type_str = data.game_info.name
local time =tonumber(create_time) local time = tonumber(create_time)
local room_time_str = os.date("%Y-%m-%d %H:%M:%S", time) local room_time_str = os.date("%Y-%m-%d %H:%M:%S", time)
local totalScore = json.decode(data.totalScore) local totalScore = json.decode(data.totalScore)
local hpOnOff = data.hpOnOff local hpOnOff = data.hpOnOff
@ -142,18 +140,18 @@ function M:FillRecordItem(data, obj)
obj:GetChild("tex_time").text = room_time_str obj:GetChild("tex_time").text = room_time_str
obj:GetChild("tex_roomid").text = room_id obj:GetChild("tex_roomid").text = room_id
obj:GetChild("tex_times").text = d2ad(data.hp_times).."" obj:GetChild("tex_times").text = d2ad(data.hp_times) .. ""
obj:GetChild("tex_game").text = play_name obj:GetChild("tex_game").text = play_name
local lst_total = obj:GetChild("lst_total") local lst_total = obj:GetChild("lst_total")
lst_total:RemoveChildrenToPool() lst_total:RemoveChildrenToPool()
local ids = {} local ids = {}
for j=1,#totalScore do for j = 1, #totalScore do
local titem = lst_total:AddItemFromPool() local titem = lst_total:AddItemFromPool()
local trdata = totalScore[j] local trdata = totalScore[j]
titem:GetChild("tex_name").text = ViewUtil.stringEllipsis(trdata.nick) titem:GetChild("tex_name").text = ViewUtil.stringEllipsis(trdata.nick)
titem:GetChild("tex_id").text = trdata.accId and ("ID:"..trdata.accId) or "" titem:GetChild("tex_id").text = trdata.accId and ("ID:" .. trdata.accId) or ""
table.insert( ids,trdata.accId ) table.insert(ids, trdata.accId)
local score = trdata.score local score = trdata.score
if trdata.hp == nil then if trdata.hp == nil then
if hpOnOff == 1 and hpType > 1 then if hpOnOff == 1 and hpType > 1 then
@ -186,17 +184,18 @@ function M:FillRecordItem(data, obj)
ShareChatRoom(room_id, tostring(os.time()), data.round, room_type_str, self.group_id, player_list) ShareChatRoom(room_id, tostring(os.time()), data.round, room_type_str, self.group_id, player_list)
end) end)
obj.onClick:Set(function() obj.onClick:Set(function()
self:OnShowRecordInfo(data,ids) self:OnShowRecordInfo(data, ids)
end) end)
end end
function M:OnRenderRecordItem(index, obj) function M:OnRenderRecordItem(index, obj)
local data = self.record_data[index + 1] local data = self.record_data[index + 1]
data.seat = 2 - (index + 1) % 2
self:FillRecordItem(data, obj) self:FillRecordItem(data, obj)
end end
function M:OnRenderRecordItem1(index, obj) function M:OnRenderRecordItem1(index, obj)
local data=self.tempRec[index+1] local data = self.tempRec[index + 1]
self:FillRecordItem(data, obj) self:FillRecordItem(data, obj)
end end
@ -205,7 +204,6 @@ function M:OnRenderPlayerRecordItem(index, obj)
self:FillRecordItem(data, obj) self:FillRecordItem(data, obj)
end end
function M:GetRecordByRoomid() function M:GetRecordByRoomid()
local qid = self._view:GetChild("tex_id").text local qid = self._view:GetChild("tex_id").text
ViewUtil.ShowModalWait() ViewUtil.ShowModalWait()
@ -222,7 +220,7 @@ function M:GetRecordByRoomid()
ViewUtil.ErrorTip(nil, "没有找到回放") ViewUtil.ErrorTip(nil, "没有找到回放")
return return
end end
self.tempRec=res.Data.rec self.tempRec = res.Data.rec
self.lst_record_find.numItems = #res.Data.rec self.lst_record_find.numItems = #res.Data.rec
self._view:GetController("search").selectedIndex = 1 self._view:GetController("search").selectedIndex = 1
@ -254,14 +252,14 @@ function M:OnShareScreenShot(room_id, room_type_str, room_time_str, totalScore,
item:GetChild("score").text = score item:GetChild("score").text = score
if score < 0 then item:GetController("di").selectedIndex = 1 end if score < 0 then item:GetController("di").selectedIndex = 1 end
if p.portrait and p.portrait ~= "" then if p.portrait and p.portrait ~= "" then
ImageLoad.Load(p.portrait, item:GetChild("n9")._iconObject, self.class, function( ... ) ImageLoad.Load(p.portrait, item:GetChild("n9")._iconObject, self.class, function(...)
load_head_num = load_head_num - 1 load_head_num = load_head_num - 1
end) end)
else else
load_head_num = load_head_num - 1 load_head_num = load_head_num - 1
end end
end end
coroutine.start(function ( ... ) coroutine.start(function(...)
local left_time = 4 local left_time = 4
while (true) do while (true) do
if load_head_num == 0 or left_time == 0 then if load_head_num == 0 or left_time == 0 then
@ -279,7 +277,7 @@ function M:OnShareScreenShot(room_id, room_type_str, room_time_str, totalScore,
end) end)
end end
function M:OnShowRecordInfo(rdata,ids) function M:OnShowRecordInfo(rdata, ids)
local ctr_record = self._view:GetController("record") local ctr_record = self._view:GetController("record")
ctr_record.selectedIndex = 1 ctr_record.selectedIndex = 1
@ -292,21 +290,21 @@ function M:OnShowRecordInfo(rdata,ids)
local hpOnOff = rdata.hpOnOff local hpOnOff = rdata.hpOnOff
local hpType = rdata.game_info.hpType local hpType = rdata.game_info.hpType
local play_name = DataManager.groups:get(self.group_id):getPlayName(rdata.groupPid) local play_name = DataManager.groups:get(self.group_id):getPlayName(rdata.groupPid)
for i = 1,round_count do for i = 1, round_count do
local item = lst_recordInfo:AddItemFromPool() local item = lst_recordInfo:AddItemFromPool()
item:GetChild("tex_num").text = tostring(i) item:GetChild("tex_num").text = tostring(i)
item:GetChild("tex_game").text = play_name item:GetChild("tex_game").text = play_name
item:GetChild("tex_times").text = d2ad(rdata.hp_times).."" item:GetChild("tex_times").text = d2ad(rdata.hp_times) .. ""
item:GetChild("tex_roomid").text = rdata.room_id item:GetChild("tex_roomid").text = rdata.room_id
local round_score_str = rdata["round_"..i] local round_score_str = rdata["round_" .. i]
local round_score_item = json.decode(round_score_str) local round_score_item = json.decode(round_score_str)
local lst_total = item:GetChild("lst_total") local lst_total = item:GetChild("lst_total")
lst_total:RemoveChildrenToPool() lst_total:RemoveChildrenToPool()
for k=1,#round_score_item do for k = 1, #round_score_item do
local titem = lst_total:AddItemFromPool() local titem = lst_total:AddItemFromPool()
local trdata = round_score_item[k] local trdata = round_score_item[k]
titem:GetChild("tex_name").text = ViewUtil.stringEllipsis(trdata.nick) titem:GetChild("tex_name").text = ViewUtil.stringEllipsis(trdata.nick)
titem:GetChild("tex_id").text = "ID:".. ids[k] titem:GetChild("tex_id").text = "ID:" .. ids[k]
local score = trdata.score local score = trdata.score
if trdata.hp == nil then if trdata.hp == nil then
if hpOnOff == 1 and hpType > 1 then if hpOnOff == 1 and hpType > 1 then
@ -325,7 +323,7 @@ function M:OnShowRecordInfo(rdata,ids)
item:GetController("person_num").selectedIndex = 0 item:GetController("person_num").selectedIndex = 0
end end
local btn_play =item:GetChild("btn_play") local btn_play = item:GetChild("btn_play")
btn_play.onClick:Set(function() btn_play.onClick:Set(function()
local group = DataManager.groups:get(self.group_id) local group = DataManager.groups:get(self.group_id)
if DataManager.SelfUser.playback[playback_id] ~= nil and DataManager.SelfUser.playback[playback_id][i] ~= nil then if DataManager.SelfUser.playback[playback_id] ~= nil and DataManager.SelfUser.playback[playback_id][i] ~= nil then
@ -336,7 +334,7 @@ function M:OnShowRecordInfo(rdata,ids)
local extend = ExtendManager.GetExtendConfig(game_id) local extend = ExtendManager.GetExtendConfig(game_id)
extend:FillPlayBackData(DataManager.SelfUser.playback[playback_id][i]) extend:FillPlayBackData(DataManager.SelfUser.playback[playback_id][i])
if not room.self_player then if not room.self_player then
room.self_player = room:GetPlayerBySeat(1) room.self_player = room:GetPlayerBySeat(rdata.seat)
end end
local main = self:GenaratePlayBack(ViewManager.View_PlayBack, game_id) local main = self:GenaratePlayBack(ViewManager.View_PlayBack, game_id)
main._currentId = playback_id main._currentId = playback_id
@ -349,17 +347,19 @@ function M:OnShowRecordInfo(rdata,ids)
_data["military_id"] = playback_id _data["military_id"] = playback_id
_data["round"] = tostring(i) _data["round"] = tostring(i)
local loddyCtr1 = ControllerManager.GetController(LoddyController) local loddyCtr1 = ControllerManager.GetController(LoddyController)
loddyCtr1:RequestPlayBack(_data,function(code,data) loddyCtr1:RequestPlayBack(_data, function(code, data)
ViewUtil.CloseModalWait() ViewUtil.CloseModalWait()
if code == 0 then if code == 0 then
if DataManager.SelfUser.playback[playback_id] ~= nil then if group.lev == 1 then
DataManager.SelfUser.playback[playback_id][i] = data DataManager.CurrenRoom.self_player = DataManager.CurrenRoom:GetPlayerBySeat(rdata.seat)
else
local playback_data = {}
playback_data[i] = data
DataManager.SelfUser.playback[playback_id] = playback_data
end end
-- 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) local main = self:GenaratePlayBack(ViewManager.View_PlayBack, game_id)
main._currentId = playback_id main._currentId = playback_id
main._currentRound = i main._currentRound = i
@ -377,7 +377,7 @@ function M:OnShowRecordInfo(rdata,ids)
end end
function M:GenaratePlayBack(id, game_id, ...) function M:GenaratePlayBack(id, game_id, ...)
local tem =nil local tem = nil
local dview_class = nil local dview_class = nil
if not dview_class then if not dview_class then
local exconfig = ExtendManager.GetExtendConfig(game_id) local exconfig = ExtendManager.GetExtendConfig(game_id)
@ -386,7 +386,7 @@ function M:GenaratePlayBack(id, game_id, ...)
if not dview_class then if not dview_class then
return return
end end
local arg = {...} local arg = { ... }
tem = dview_class.new(...) tem = dview_class.new(...)
tem.Id = id tem.Id = id
tem:Show() tem:Show()

View File

@ -308,14 +308,10 @@ function M:CmdBackToLobby()
_curren_msg:Show() _curren_msg:Show()
end end
function M:GetPos(seat,myseat) function M:GetPos(seat, myseat)
local my_seat = 1 local my_seat = 1
if myseat == nil then if not myseat then
for i = 1, #self._room.player_list do my_seat = self._room.self_player.seat
if DataManager.SelfUser.account_id == self._room.player_list[i].self_user.account_id then
my_seat = self._room.player_list[i].seat
end
end
else else
my_seat = myseat my_seat = myseat
end end

View File

@ -4,7 +4,7 @@ local EXGameInfo = import(".EXGameInfo")
local EXMainView = import(".EXMainView") local EXMainView = import(".EXMainView")
local EXGameController = import(".EXGameController") local EXGameController = import(".EXGameController")
local EXRoomConfig = import(".EXRoomConfig") local EXRoomConfig = import(".EXRoomConfig")
local EXPlayBackView =import(".EXPlayBackView") local EXPlayBackView = import(".EXPlayBackView")
local MJRoom = require("main.majiang.MJRoom") local MJRoom = require("main.majiang.MJRoom")
local ExtendConfig = {} local ExtendConfig = {}
@ -13,8 +13,8 @@ local M = ExtendConfig
function ExtendConfig.new() function ExtendConfig.new()
setmetatable(M, {__index = IExtendConfig}) setmetatable(M, { __index = IExtendConfig })
local self = setmetatable({}, {__index = M}) local self = setmetatable({}, { __index = M })
self.class = "ExtendConfig" self.class = "ExtendConfig"
self.extend_id = 22 self.extend_id = 22
self._viewMap = {} self._viewMap = {}
@ -55,7 +55,7 @@ function M:NewRoom()
return MJRoom.new() return MJRoom.new()
end end
function M:FillRoomConfig(room,_config) function M:FillRoomConfig(room, _config)
room.room_config = EXRoomConfig.new(_config) room.room_config = EXRoomConfig.new(_config)
end end
@ -88,7 +88,7 @@ function M:FillRoomData(s2croom)
room.curren_outcard_seat = _reloadInfo["curren_outcard_seat"] room.curren_outcard_seat = _reloadInfo["curren_outcard_seat"]
room.last_outcard_seat = last_outcard_seat room.last_outcard_seat = last_outcard_seat
room.playing = playing room.playing = playing
for i=1,#_info_list do for i = 1, #_info_list do
local tem = _info_list[i] local tem = _info_list[i]
local playerid = tem["playerid"] local playerid = tem["playerid"]
local p = room:GetPlayerById(playerid) local p = room:GetPlayerById(playerid)
@ -98,12 +98,12 @@ function M:FillRoomData(s2croom)
p.hand_left_count = tem["card_count"] p.hand_left_count = tem["card_count"]
p.piao_niao = tem["piao_niao"] or 0 p.piao_niao = tem["piao_niao"] or 0
local opcard = tem["opcard"] local opcard = tem["opcard"]
for k=1,#opcard do for k = 1, #opcard do
local op = opcard[k] local op = opcard[k]
local fz = {} local fz = {}
fz.type = op["type"] fz.type = op["type"]
fz.card = op["card"] fz.card = op["card"]
p.fz_list[#p.fz_list+1] = fz p.fz_list[#p.fz_list + 1] = fz
end end
if not playing and room.curren_round > 0 then if not playing and room.curren_round > 0 then
self.GetGameController():PlayerReady() self.GetGameController():PlayerReady()
@ -128,7 +128,8 @@ function M:FillPlayBackData(pd_data)
room.curren_round = _tableInfo["round"] room.curren_round = _tableInfo["round"]
local _info_list = _tableInfo["playerData"] local _info_list = _tableInfo["playerData"]
for i = 1,#_info_list do
for i = 1, #_info_list do
local _jp = _info_list[i] local _jp = _info_list[i]
local p = room:NewPlayer() local p = room:NewPlayer()
p.seat = _jp["seat"] p.seat = _jp["seat"]
@ -164,6 +165,7 @@ function M:FillPlayBackData(pd_data)
room:AddPlayer(p) room:AddPlayer(p)
end end
room.cmdList = pd_data["cmdList"] room.cmdList = pd_data["cmdList"]
end end

View File

@ -11,8 +11,8 @@ local ExtendConfig = {}
local M = ExtendConfig local M = ExtendConfig
function ExtendConfig.new() function ExtendConfig.new()
setmetatable(M, {__index = IExtendConfig}) setmetatable(M, { __index = IExtendConfig })
local self = setmetatable({}, {__index = M}) local self = setmetatable({}, { __index = M })
self.class = 'ExtendConfig' self.class = 'ExtendConfig'
self.extend_id = 13 self.extend_id = 13
self._viewMap = {} self._viewMap = {}

View File

@ -2,22 +2,22 @@ local MJPlayerCardInfoView = import(".MJPlayerCardInfoView")
local MJPlayerSelfCardInfoView = import(".MJPlayerSelfCardInfoView") local MJPlayerSelfCardInfoView = import(".MJPlayerSelfCardInfoView")
local TableBG = import('Game.Data.TableBG') local TableBG = import('Game.Data.TableBG')
--- ---
local M = {} local M = {}
setmetatable(M,{__index = PlayBackView}) setmetatable(M, { __index = PlayBackView })
local bg_config = { local bg_config = {
{id = 1, url = "base/main_majiang/bg/bg1", thumb = "ui://Main_Majiang/b01"} { id = 1, url = "base/main_majiang/bg/bg1", thumb = "ui://Main_Majiang/b01" }
} }
function M:InitView(url) function M:InitView(url)
UIPackage.AddPackage("base/main_majiang/ui/Main_Majiang") UIPackage.AddPackage("base/main_majiang/ui/Main_Majiang")
PlayBackView.InitView(self,url) PlayBackView.InitView(self, url)
local _view = self._view local _view = self._view
self._cursor = UIPackage.CreateObjectFromURL("ui://Main_Majiang/Ani_play_bj") self._cursor = UIPackage.CreateObjectFromURL("ui://Main_Majiang/Ani_play_bj")
TableBG.LoadTableBG(1, nil, self._root_view,bg_config) TableBG.LoadTableBG(1, nil, self._root_view, bg_config)
UpdateBeat:Add(self.OnUpdate,self) UpdateBeat:Add(self.OnUpdate, self)
end end
function M:FillRoomData() function M:FillRoomData()
@ -27,13 +27,13 @@ function M:FillRoomData()
local _player_card_info = self._player_card_info local _player_card_info = self._player_card_info
for i = 1, _room.room_config.people_num do for i = 1, _room.room_config.people_num do
local tem = self._view:GetChild("player_card_info" .. i) local tem = self._view:GetChild("player_card_info" .. i)
_player_card_info[i] = self:NewMJPlayerCardInfoView(tem,i) _player_card_info[i] = self:NewMJPlayerCardInfoView(tem, i)
end end
end end
local list = _room.player_list local list = _room.player_list
for i=1,#list do for i = 1, #list do
local p = list[i] local p = list[i]
local info = self._player_card_info[self:GetPos(p.seat)] local info = self._player_card_info[self:GetPos(p.seat)]
info:SetPlayer(p) info:SetPlayer(p)
@ -42,7 +42,7 @@ function M:FillRoomData()
self:SetCardBoxPosition() self:SetCardBoxPosition()
local list = _room.player_list local list = _room.player_list
for i=1,#list do for i = 1, #list do
local p = list[i] local p = list[i]
local info = self._player_info[self:GetPos(p.seat)] local info = self._player_info[self:GetPos(p.seat)]
info._view.visible = true info._view.visible = true
@ -53,15 +53,15 @@ end
function M:SetCardBoxPosition() function M:SetCardBoxPosition()
local _room = self._room local _room = self._room
for i = 1, _room.room_config.people_num do for i = 1, _room.room_config.people_num do
local tex = self._view:GetChild("cardbox"):GetChild("direction"..i) local tex = self._view:GetChild("cardbox"):GetChild("direction" .. i)
local index = _room.self_player.seat + i - 1 local index = _room.self_player.seat + i - 1
index = index > 4 and index - 4 or index index = index > 4 and index - 4 or index
tex.text = self._gamectr:GetPosString(index) tex.text = self._gamectr:GetPosString(index)
end end
end end
function M:NewMJPlayerCardInfoView(view,index) function M:NewMJPlayerCardInfoView(view, index)
return MJPlayerCardInfoView.new(view,self) return MJPlayerCardInfoView.new(view, self)
end end
function M:NextRecordPlay() function M:NextRecordPlay()
@ -110,7 +110,8 @@ end
function M:ChangeTextSpeed() function M:ChangeTextSpeed()
local str1 = self._play and self._speed or "" local str1 = self._play and self._speed or ""
self._view:GetChild("panel_record"):GetChild("tex_speed").text = str1 self._view:GetChild("panel_record"):GetChild("tex_speed").text = str1
local str2 = not self._play and (self._playFoward and "播放暂停" or "回退暂停") or self._playFoward and (self._speed == 1 and "播放" or "快进") or (self._speed == 1 and "回退" or "快退") local str2 = not self._play and (self._playFoward and "播放暂停" or "回退暂停") or
self._playFoward and (self._speed == 1 and "播放" or "快进") or (self._speed == 1 and "回退" or "快退")
self._view:GetChild("panel_record"):GetChild("tex_2").text = str2 self._view:GetChild("panel_record"):GetChild("tex_2").text = str2
local str3 = self._play and "倍速度" or "" local str3 = self._play and "倍速度" or ""
self._view:GetChild("panel_record"):GetChild("tex_1").text = str3 self._view:GetChild("panel_record"):GetChild("tex_1").text = str3
@ -154,11 +155,11 @@ function M:OnUpdate()
if self._play then if self._play then
if (self._currentStep == #self.cmdList and self._playFoward) then if (self._currentStep == #self.cmdList and self._playFoward) then
self:ChangePlayState(false) self:ChangePlayState(false)
ViewUtil.ErrorTip(nil,"当前已是录像结尾了,再次点击播放按钮可重新播放") ViewUtil.ErrorTip(nil, "当前已是录像结尾了,再次点击播放按钮可重新播放")
return return
elseif (self._currentStep == 0 and not self._playFoward) then elseif (self._currentStep == 0 and not self._playFoward) then
self:ChangePlayState(false) self:ChangePlayState(false)
ViewUtil.ErrorTip(nil,"当前已是录像开头了,再次点击播放按钮可重新播放") ViewUtil.ErrorTip(nil, "当前已是录像开头了,再次点击播放按钮可重新播放")
return return
end end
self._timer = self._timer + Time.deltaTime self._timer = self._timer + Time.deltaTime
@ -184,7 +185,7 @@ end
function M:Destroy() function M:Destroy()
if self._cursor then self._cursor:Dispose() end if self._cursor then self._cursor:Dispose() end
UpdateBeat:Remove(self.OnUpdate,self) UpdateBeat:Remove(self.OnUpdate, self)
PlayBackView.Destroy(self) PlayBackView.Destroy(self)
end end