2025-06-25 22:21:05 +08:00
|
|
|
--region LOCAL
|
|
|
|
|
|
2025-07-05 21:36:09 +08:00
|
|
|
local function SetBigWiller(totalScore)
|
|
|
|
|
local s = -999
|
|
|
|
|
local winer = 0
|
2025-07-11 16:05:11 +08:00
|
|
|
for _, player in pairs(totalScore) do
|
|
|
|
|
if player.score > s then
|
2025-07-05 21:36:09 +08:00
|
|
|
s = player.score
|
|
|
|
|
winer = _
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
totalScore[winer].winer = true
|
|
|
|
|
end
|
|
|
|
|
|
2025-07-30 19:40:37 +08:00
|
|
|
local function list_players_Renderer(index, obj, players, self)
|
2025-06-25 22:21:05 +08:00
|
|
|
local tex_name = obj:GetChild("tex_name")
|
2025-07-05 21:36:09 +08:00
|
|
|
local loader_icon = obj:GetChild("loader_icon")
|
2025-06-25 22:21:05 +08:00
|
|
|
local tex_id = obj:GetChild("tex_id")
|
|
|
|
|
local tex_score = obj:GetChild("tex_score")
|
|
|
|
|
|
2025-07-30 19:40:37 +08:00
|
|
|
local player = players[index + 1]
|
2025-07-11 16:05:11 +08:00
|
|
|
|
2025-07-05 21:36:09 +08:00
|
|
|
tex_name.text = player.nick
|
|
|
|
|
tex_id.text = player.accId
|
2025-09-08 14:39:21 +08:00
|
|
|
tex_score.text = string.format("%s%s", player.score >= 0 and "+" or "", player.score)
|
2025-09-03 21:58:19 +08:00
|
|
|
obj:GetController('cCouler').selectedIndex = player.score >= 0 and 0 or 1
|
2025-07-05 21:36:09 +08:00
|
|
|
ImageLoad.Load(player.portrait, loader_icon)
|
|
|
|
|
|
2025-07-11 16:05:11 +08:00
|
|
|
if player.winer then
|
2025-07-05 21:36:09 +08:00
|
|
|
obj:GetController("cWiner").selectedIndex = 1
|
2025-07-11 16:05:11 +08:00
|
|
|
else
|
2025-07-05 21:36:09 +08:00
|
|
|
obj:GetController("cWiner").selectedIndex = 0
|
|
|
|
|
end
|
2025-06-25 22:21:05 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
local function ChatItemRenderer(index, obj, self)
|
2025-07-07 17:42:23 +08:00
|
|
|
--local data = self.ChatRoomData.records[index + 1]
|
2025-07-30 19:40:37 +08:00
|
|
|
local record = self.group.records[index + 1]
|
|
|
|
|
local group = DataManager.groups:get(record.groupId)
|
|
|
|
|
--local totalScore = json.decode(data.totalScore)
|
|
|
|
|
--local hpData = json.decode(record.hpData)
|
|
|
|
|
SetBigWiller(record.players)
|
2025-07-05 21:36:09 +08:00
|
|
|
|
2025-06-25 22:21:05 +08:00
|
|
|
local list_players = obj:GetChild("list_players")
|
|
|
|
|
local tex_time = obj:GetChild("tex_time")
|
|
|
|
|
local tex_name = obj:GetChild("tex_name")
|
2025-07-07 19:49:16 +08:00
|
|
|
local tex_roomIdRound = obj:GetChild("tex_roomIdRound")
|
2025-06-25 22:21:05 +08:00
|
|
|
|
2025-09-03 21:58:19 +08:00
|
|
|
tex_time.text = os.date("游戏结算:%m月%d号 %X", record.create_time) --data.create_time
|
2025-09-08 14:39:21 +08:00
|
|
|
tex_name.text = record.game_info.name
|
2025-07-30 19:40:37 +08:00
|
|
|
local roundTex = record.round .. "/" .. record.maxRound
|
|
|
|
|
tex_roomIdRound.text = record.room_id .. "\n" .. roundTex
|
2025-07-05 21:36:09 +08:00
|
|
|
|
|
|
|
|
list_players.itemRenderer = function(i, o)
|
2025-07-30 19:40:37 +08:00
|
|
|
list_players_Renderer(i, o, record.players, self)
|
2025-07-05 21:36:09 +08:00
|
|
|
end
|
2025-06-25 22:21:05 +08:00
|
|
|
|
2025-07-30 19:40:37 +08:00
|
|
|
list_players.numItems = #record.players
|
2025-06-25 22:21:05 +08:00
|
|
|
end
|
|
|
|
|
|
2025-07-05 21:36:09 +08:00
|
|
|
--[[
|
2025-06-25 22:21:05 +08:00
|
|
|
local function GetIsOpenChatRoom(groupId, self)
|
|
|
|
|
local fgCtr = ControllerManager.GetController(NewGroupController)
|
|
|
|
|
fgCtr:GetIsOpenChatRoom(groupId, function(res)
|
|
|
|
|
print("收到是否打开聊天室协议")
|
|
|
|
|
pt(res)
|
|
|
|
|
end)
|
|
|
|
|
end
|
2025-07-05 21:36:09 +08:00
|
|
|
]]
|
2025-06-25 22:21:05 +08:00
|
|
|
|
|
|
|
|
--endregion
|
|
|
|
|
|
2025-06-25 22:49:44 +08:00
|
|
|
local FamilyChatRoom = {}
|
|
|
|
|
|
|
|
|
|
--[[
|
|
|
|
|
function FamilyChatRoom.New()
|
|
|
|
|
--转移进family界面
|
|
|
|
|
--setmetatable(FamilyChatRoom, { __index = BaseWindow })
|
|
|
|
|
--local inst = setmetatable({}, { __index = FamilyChatRoom})
|
|
|
|
|
|
|
|
|
|
inst:Init(com)
|
|
|
|
|
|
|
|
|
|
return inst
|
|
|
|
|
end
|
|
|
|
|
]]
|
|
|
|
|
|
|
|
|
|
function FamilyChatRoom:Init(com, root)
|
|
|
|
|
--转移进family界面
|
|
|
|
|
--self._full = true
|
|
|
|
|
--self._full_offset = false
|
|
|
|
|
--self._animation = false
|
|
|
|
|
--BaseWindow.init(self, "ui://Family/com_chatRoom")
|
2025-06-25 22:21:05 +08:00
|
|
|
self.rendererData = {}
|
2025-06-25 22:49:44 +08:00
|
|
|
self.root = root
|
|
|
|
|
self._view = com
|
|
|
|
|
|
|
|
|
|
self.list_chat = self._view:GetChild("list_chat")
|
|
|
|
|
self.btn_quit = self._view:GetChild("btn_quit")
|
|
|
|
|
|
2025-07-28 20:42:56 +08:00
|
|
|
self.list_chat:SetVirtual()
|
|
|
|
|
|
2025-07-05 21:36:09 +08:00
|
|
|
self.list_chat.itemRenderer = function(index, obj)
|
|
|
|
|
ChatItemRenderer(index, obj, self)
|
|
|
|
|
end
|
2025-06-25 22:21:05 +08:00
|
|
|
|
2025-06-25 22:49:44 +08:00
|
|
|
self.btn_quit.onClick:Set(function()
|
|
|
|
|
self:Close()
|
|
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
return self
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function FamilyChatRoom:Close()
|
|
|
|
|
local cChatRoom = self.root._view:GetController("cIsChatRoom")
|
|
|
|
|
cChatRoom.selectedIndex = 0
|
2025-07-28 20:42:56 +08:00
|
|
|
|
|
|
|
|
self.group.messageCount = 0
|
|
|
|
|
self.root:ReflashChatRoomRedPoint()
|
2025-06-25 22:49:44 +08:00
|
|
|
end
|
|
|
|
|
|
2025-07-05 21:36:09 +08:00
|
|
|
function FamilyChatRoom:Refalsh()
|
2025-07-28 20:42:56 +08:00
|
|
|
--self.list_chat.numItems = #self.ChatRoomData.records or 0
|
|
|
|
|
self.list_chat.numItems = #self.group.records or 0
|
2025-07-05 21:36:09 +08:00
|
|
|
end
|
|
|
|
|
|
2025-07-11 16:05:11 +08:00
|
|
|
-- 新战绩推到时刷新一条
|
|
|
|
|
function FamilyChatRoom:OnNewChatRefalsh(arg)
|
2025-07-30 21:55:34 +08:00
|
|
|
if self.group == nil then
|
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
|
2025-07-28 20:42:56 +08:00
|
|
|
self.list_chat.numItems = #self.group.records or 0
|
|
|
|
|
|
|
|
|
|
--[[
|
2025-07-11 16:05:11 +08:00
|
|
|
local groupId = arg.gid
|
|
|
|
|
local maxRound = arg.datas.maxRound
|
|
|
|
|
local round = arg.datas.round
|
|
|
|
|
local playerlist = arg.datas.datas
|
|
|
|
|
local time = arg.datas.time
|
|
|
|
|
local roomId = arg.datas.roomid
|
|
|
|
|
local pid = arg.datas.pid
|
|
|
|
|
local group = DataManager.groups.groupMap[groupId]
|
|
|
|
|
local play = group:getPlay(pid)
|
|
|
|
|
local gameName = play.game_name
|
|
|
|
|
|
|
|
|
|
local obj = self.list_chat:AddItemFromPool()
|
|
|
|
|
local list_players = obj:GetChild("list_players")
|
|
|
|
|
local tex_time = obj:GetChild("tex_time")
|
|
|
|
|
local tex_name = obj:GetChild("tex_name")
|
|
|
|
|
local tex_roomIdRound = obj:GetChild("tex_roomIdRound")
|
2025-06-25 22:49:44 +08:00
|
|
|
|
2025-07-11 16:05:11 +08:00
|
|
|
tex_time.text = os.date("游戏结算:%m月%d号 %X", time) --data.create_time
|
|
|
|
|
tex_name.text = gameName
|
|
|
|
|
local roundTex = round .. "/" .. maxRound
|
|
|
|
|
tex_roomIdRound.text = roomId .. "\n" .. roundTex
|
2025-06-25 22:21:05 +08:00
|
|
|
|
2025-07-28 20:42:56 +08:00
|
|
|
SetBigWiller(playerlist)
|
2025-07-11 16:05:11 +08:00
|
|
|
|
2025-07-28 20:42:56 +08:00
|
|
|
for _, player in pairs(playerlist) do
|
2025-07-11 16:05:11 +08:00
|
|
|
local pObj = list_players:AddItemFromPool()
|
|
|
|
|
|
|
|
|
|
local tex_name = pObj:GetChild("tex_name")
|
|
|
|
|
local loader_icon = pObj:GetChild("loader_icon")
|
|
|
|
|
local tex_id = pObj:GetChild("tex_id")
|
|
|
|
|
local tex_score = pObj:GetChild("tex_score")
|
|
|
|
|
|
|
|
|
|
tex_name.text = player.nick
|
|
|
|
|
tex_id.text = player.accId
|
|
|
|
|
tex_score.text = player.score
|
|
|
|
|
ImageLoad.Load(player.portrait, loader_icon)
|
2025-07-28 20:42:56 +08:00
|
|
|
|
|
|
|
|
if player.winer then
|
|
|
|
|
pObj:GetController("cWiner").selectedIndex = 1
|
|
|
|
|
else
|
|
|
|
|
pObj:GetController("cWiner").selectedIndex = 0
|
|
|
|
|
end
|
2025-07-11 16:05:11 +08:00
|
|
|
end
|
2025-07-28 20:42:56 +08:00
|
|
|
]]
|
2025-06-25 22:49:44 +08:00
|
|
|
end
|
|
|
|
|
|
2025-07-11 16:05:11 +08:00
|
|
|
function FamilyChatRoom:Show()
|
2025-07-28 20:42:56 +08:00
|
|
|
local mgr_ctr = ControllerManager.GetController(GroupMgrController)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
local groupId = self.root._group.id
|
|
|
|
|
self.group = DataManager.groups:get(groupId)
|
|
|
|
|
|
|
|
|
|
local getData = self.group.records == nil
|
|
|
|
|
|
|
|
|
|
mgr_ctr:FG_ENTER_CHATROOM(self.root._group.id, getData, function(res)
|
2025-07-29 01:17:29 +08:00
|
|
|
if res.returnCode == 0 then
|
|
|
|
|
ViewUtil.ShowModalWait(self._root_view, "正在加载聊天室......")
|
|
|
|
|
end
|
2025-07-28 20:42:56 +08:00
|
|
|
end)
|
|
|
|
|
|
2025-07-11 16:05:11 +08:00
|
|
|
local cChatRoom = self.root._view:GetController("cIsChatRoom")
|
|
|
|
|
cChatRoom.selectedIndex = 1
|
2025-06-25 22:49:44 +08:00
|
|
|
end
|
|
|
|
|
|
2025-07-11 16:05:11 +08:00
|
|
|
return FamilyChatRoom
|