hengyang_client/lua_probject/base_project/Game/View/Family/FamilyChatRoom.lua

168 lines
4.6 KiB
Lua
Raw Normal View History

2025-06-25 22:49:44 +08:00
require 'FairyGUI'
--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
local function list_players_Renderer(index, obj, totalScore, self)
local tex_name = obj:GetChild("tex_name")
2025-07-05 21:36:09 +08:00
local loader_icon = obj:GetChild("loader_icon")
local tex_id = obj:GetChild("tex_id")
local tex_score = obj:GetChild("tex_score")
2025-07-05 21:36:09 +08:00
local player = totalScore[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
tex_score.text = player.score
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
end
local function ChatItemRenderer(index, obj, self)
2025-07-07 17:42:23 +08:00
--local data = self.ChatRoomData.records[index + 1]
local data = self.ChatRoomData[1].records[index + 1]
2025-07-05 21:36:09 +08:00
local totalScore = json.decode(data.totalScore)
2025-07-07 19:49:16 +08:00
local hpData = json.decode(data.hpData)
2025-07-05 21:36:09 +08:00
SetBigWiller(totalScore)
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-07-07 19:49:16 +08:00
tex_time.text = os.date("游戏结算:%m月%d号 %X", data.create_time) --data.create_time
2025-07-05 21:36:09 +08:00
tex_name.text = data.game_info.name
2025-07-07 19:49:16 +08:00
local roundTex = data.round .. "/" .. hpData.maxRound
tex_roomIdRound.text = data.room_id .. "\n" .. roundTex
2025-07-05 21:36:09 +08:00
list_players.itemRenderer = function(i, o)
list_players_Renderer(i, o, totalScore, self)
end
2025-07-05 21:36:09 +08:00
list_players.numItems = #totalScore
end
2025-07-05 21:36:09 +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
]]
--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")
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-05 21:36:09 +08:00
self.list_chat.itemRenderer = function(index, obj)
ChatItemRenderer(index, obj, self)
end
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
end
2025-07-05 21:36:09 +08:00
function FamilyChatRoom:Refalsh()
2025-07-07 16:09:48 +08:00
pt(self.ChatRoomData[1])
2025-07-07 17:42:23 +08:00
self.list_chat.numItems = #self.ChatRoomData[1].records or 0
2025-07-05 21:36:09 +08:00
end
2025-07-11 16:05:11 +08:00
-- 新战绩推到时刷新一条
function FamilyChatRoom:OnNewChatRefalsh(arg)
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-07-11 16:05:11 +08:00
for _, player in pairs(playerlist) do
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)
end
2025-06-25 22:49:44 +08:00
end
2025-07-11 16:05:11 +08:00
function FamilyChatRoom:Show()
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